-
Notifications
You must be signed in to change notification settings - Fork 1.8k
UITests
To run the tests on iOS or Catalyst, you'll need a Mac. To run the tests on Windows, you'll need a Windows machine. Android tests can be run from either platform.
├── Controls
│ ├── tests
│ ├── ├── Controls.TestCases.App
│ │ ├── Controls.TestCases.Shared.Tests
- Controls.TestCases.App: .NET MAUI Sample used for the automated UI tests
- Controls.TestCases.Shared.Tests: .NET MAUI library used to define the UI tests
Each platform has a specific UI tests library project where it is possible to add specific tests per platform.
├── Controls
│ ├── tests
│ │ ├── Controls.TestCases.Android.Tests
│ │ ├── Controls.TestCases.iOS.Tests
│ │ ├── Controls.TestCases.Mac.Tests
│ │ ├── Controls.TestCases.WinUI.Tests
https://github.com/dotnet/maui/blob/main/docs/design/UITesting.md
- make sure a
dotnet tool restore
on the repo home - Make sure DeveloperMode is turned on
- Install LTS version of nodejs https://nodejs.org
- Install Windows App Driver from https://github.com/microsoft/WinAppDriver/releases/tag/v1.2.1
- Validate you have on your path %USERPROFILE%\AppData\Roaming\npm
- Note: you may need to restart your machine for this to take effect
- dotnet pwsh .\eng\scripts\appium-install.ps1
- Ignore "apkanalyzer.bat could NOT be found" error from appium-doctor
- make sure to run
dotnet tool restore
on the repo home
- Install LTS version of nodejs https://nodejs.org
- To install Appium run the following as sudo https://github.com/dotnet/maui/tree/main/eng/scripts/appium-install.ps1
sudo dotnet pwsh /path/to/scripts/appium-install.ps1
- brew install node
- To install Appium run the following script https://github.com/dotnet/maui/tree/main/eng/scripts/appium-install.ps1
dotnet pwsh /path/to/scripts/appium-install.ps1
-
You will need to setup the
ANDROID_HOME
andJAVA_HOME
environment variables so that Appium andandroid.cake
can find them.- https://developer.android.com/tools/variables
- Development guide has instructions for setting these variables on a MAC.
-
Ensure that you have the Android API 30 SDK installed, with the emulator image for Play store on x86/x64. By default, the tests use that. See screenshot below. If you want to use another image you can specify the
--device
argument, with something like--device="android-emulator-64_33"
where the 64 means image x86_x64 and 33 indicates the API level.
- Deploy the app
Control.Sample.UITests
to your simulator, device or on your desktop. - Build the
Controls.AppiumTests.csproj
so the tests show up on the Test Explorer - Run the tests
- If you don't have your development environment already setup, please consult the development guide.
- You'll want to deploy the app first. Go to the Run and Debug window and select the correct project:
However, this will just load the test in the app. To have Appium drive the test, you’ll need to run them in the Testing pane in VS Code. Before that, make sure to build the project where your test is located:
- Ensure that you are in Explorer.
- Expand the Solution Explorer
- Find the project that your test is located in.
- Right click and select build.
Now if you click on the Testing icon, you will see the test that you were working on. Click the play icon to launch your test:
./build.ps1 --target=dotnet-buildtasks --configuration="Release" --workloads=global
Android
./build.ps1 --target=uitest-build --configuration="Release" --workloads=global
./build.ps1 -Script eng/devices/android.cake --target=uitest --workloads=global
iOS
./build.ps1 --target=uitest-build --configuration="Release" --workloads=global
./build.ps1 -Script eng/devices/ios.cake --target=uitest --workloads=global
Windows
./build.ps1 --target=uitest-build --configuration="Release" --workloads=global
./build.ps1 -Script eng/devices/windows.cake --target=uitest --workloads=global
Catalyst
./build.ps1 --target=dotnet-samples --configuration="Release" --catalyst --verbosity=diagnostic --workloads=global --usenuget=false
./build.ps1 -Script eng/devices/catalyst.cake --target=uitest --apiversion="10.13" --configuration="Release" --device=mac
- Try starting
appium
from the command line to get a better error messagenode /usr/local/lib/node_modules/appium/build/lib/main.js