├── .config
└── dotnet-tools.json
├── .gitattributes
├── .github
├── FUNDING.yml
└── workflows
│ ├── ci-sample.yml
│ ├── ci.yml
│ ├── release-nuget.yml
│ ├── ui-test-android.yml
│ ├── ui-test-ios.yml
│ ├── ui-test-macos.yml
│ └── ui-test-windows.yml
├── .gitignore
├── LICENSE
├── README.md
├── nuget.png
├── samples
├── Plugin.Maui.UITestHelpers.Sample.sln
├── Plugin.Maui.UITestHelpers.Sample
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── AppShell.xaml
│ ├── AppShell.xaml.cs
│ ├── MainPage.xaml
│ ├── MainPage.xaml.cs
│ ├── MauiProgram.cs
│ ├── Platforms
│ │ ├── Android
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── MainActivity.cs
│ │ │ ├── MainApplication.cs
│ │ │ └── Resources
│ │ │ │ └── values
│ │ │ │ └── colors.xml
│ │ ├── MacCatalyst
│ │ │ ├── AppDelegate.cs
│ │ │ ├── Info.plist
│ │ │ └── Program.cs
│ │ ├── Tizen
│ │ │ ├── Main.cs
│ │ │ └── tizen-manifest.xml
│ │ ├── Windows
│ │ │ ├── App.xaml
│ │ │ ├── App.xaml.cs
│ │ │ ├── Package.appxmanifest
│ │ │ └── app.manifest
│ │ └── iOS
│ │ │ ├── AppDelegate.cs
│ │ │ ├── Info.plist
│ │ │ └── Program.cs
│ ├── Plugin.Maui.UITestHelpers.Sample.csproj
│ ├── Properties
│ │ └── launchSettings.json
│ └── Resources
│ │ ├── AppIcon
│ │ ├── appicon.svg
│ │ └── appiconfg.svg
│ │ ├── Fonts
│ │ ├── OpenSans-Regular.ttf
│ │ └── OpenSans-Semibold.ttf
│ │ ├── Images
│ │ └── dotnet_bot.png
│ │ ├── Raw
│ │ └── AboutAssets.txt
│ │ ├── Splash
│ │ └── splash.svg
│ │ └── Styles
│ │ ├── Colors.xaml
│ │ └── Styles.xaml
├── UITests.Android
│ └── UITests.Android.csproj
├── UITests.Shared
│ ├── AssemblyTestFixture.cs
│ ├── BaseTest.cs
│ ├── MainPageTests.cs
│ └── UITests.Shared.csproj
├── UITests.Windows
│ └── UITests.Windows.csproj
├── UITests.iOS
│ └── UITests.iOS.csproj
└── UITests.macOS
│ └── UITests.macOS.csproj
└── src
├── Plugin.Maui.UITestHelpers.Appium
├── Actions
│ ├── AppiumAndroidAlertActions.cs
│ ├── AppiumAndroidSpecificActions.cs
│ ├── AppiumAndroidThemeChangeAction.cs
│ ├── AppiumAndroidVirtualKeyboardActions.cs
│ ├── AppiumAppleAlertActions.cs
│ ├── AppiumCatalystAlertActions.cs
│ ├── AppiumCatalystMouseActions.cs
│ ├── AppiumCatalystTouchActions.cs
│ ├── AppiumCommandExecutor.cs
│ ├── AppiumDeviceActions.cs
│ ├── AppiumGeneralActions.cs
│ ├── AppiumIOSAlertActions.cs
│ ├── AppiumIOSMouseActions.cs
│ ├── AppiumIOSSpecificActions.cs
│ ├── AppiumIOSThemeChangeAction.cs
│ ├── AppiumIOSTouchActions.cs
│ ├── AppiumIOSVirtualKeyboardActions.cs
│ ├── AppiumLifecycleActions.cs
│ ├── AppiumMouseActions.cs
│ ├── AppiumOrientationActions.cs
│ ├── AppiumPinchToZoomActions.cs
│ ├── AppiumPointerActions.cs
│ ├── AppiumScrollActions.cs
│ ├── AppiumSliderActions.cs
│ ├── AppiumSwipeActions.cs
│ ├── AppiumTextActions.cs
│ ├── AppiumTouchActions.cs
│ └── AppiumVirtualKeyboardActions.cs
├── AppiumAndroidApp.cs
├── AppiumAndroidQueryable.cs
├── AppiumApp.cs
├── AppiumCatalystApp.cs
├── AppiumDriverElement.cs
├── AppiumIOSApp.cs
├── AppiumQuery.cs
├── AppiumQueryable.cs
├── AppiumServerContext.cs
├── AppiumUIClientContext.cs
├── AppiumWindowsApp.cs
├── HelperExtensions.cs
└── Plugin.Maui.UITestHelpers.Appium.csproj
├── Plugin.Maui.UITestHelpers.Core
├── ApplicationState.cs
├── CommandResponse.cs
├── CommandResponseResult.cs
├── Config.cs
├── IAndroidApp.cs
├── IApp.cs
├── ICatalystApp.cs
├── ICommandExecution.cs
├── ICommandExecutionGroup.cs
├── IConfig.cs
├── IIOSApp.cs
├── IQuery.cs
├── IServerContext.cs
├── IUIClientContext.cs
├── IUIElement.cs
├── IUIElementQueryable.cs
├── IWindowsApp.cs
├── Plugin.Maui.UITestHelpers.Core.csproj
└── TestDevice.cs
├── Plugin.Maui.UITestHelpers.NUnit
├── Plugin.Maui.UITestHelpers.NUnit.csproj
├── UITestBase.cs
├── UITestContextBase.cs
└── UITestContextSetupFixture.cs
└── Plugin.Maui.UITestHelpers.sln
/.config/dotnet-tools.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 1,
3 | "isRoot": true,
4 | "tools": {
5 | "androidsdk.tool": {
6 | "version": "0.11.0",
7 | "commands": [
8 | "android"
9 | ],
10 | "rollForward": true
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: jfversluis
4 |
--------------------------------------------------------------------------------
/.github/workflows/ci-sample.yml:
--------------------------------------------------------------------------------
1 | name: Build Sample App for CI
2 |
3 | on:
4 | push:
5 | branches: [ "main" ]
6 | paths-ignore:
7 | - "**.md"
8 | pull_request:
9 | branches: [ "main" ]
10 |
11 | env:
12 | BUILD_CONFIGURATION: Release
13 | CSPROJ_TO_BUILD: samples/Plugin.Maui.UITestHelpers.Sample/Plugin.Maui.UITestHelpers.Sample.csproj
14 |
15 | jobs:
16 | build-sample-ci:
17 |
18 | runs-on: windows-latest
19 |
20 | steps:
21 | - uses: actions/checkout@v4
22 |
23 | - name: Build Sample App
24 | run: dotnet build ${{ env.CSPROJ_TO_BUILD }} -c ${{ env.BUILD_CONFIGURATION }}
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: Build for CI
2 |
3 | on:
4 | push:
5 | branches: [ "main" ]
6 | paths-ignore:
7 | - "**.md"
8 | pull_request:
9 | branches: [ "main" ]
10 |
11 | jobs:
12 | build-plugin-ci:
13 |
14 | runs-on: windows-latest
15 |
16 | steps:
17 | - uses: actions/checkout@v4
18 | - name: Build
19 | run: dotnet build src\Plugin.Maui.UITestHelpers.sln -c Release
20 |
--------------------------------------------------------------------------------
/.github/workflows/release-nuget.yml:
--------------------------------------------------------------------------------
1 | name: Create a (Pre)release on NuGet
2 |
3 | on:
4 | push:
5 | tags:
6 | - "v[0-9]+.[0-9]+.[0-9]+"
7 | - "v[0-9]+.[0-9]+.[0-9]+-preview[0-9]+"
8 | jobs:
9 | release-nuget:
10 |
11 | runs-on: windows-latest
12 |
13 | steps:
14 | - uses: actions/checkout@v4
15 | - name: Verify commit exists in origin/main
16 | run: |
17 | git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
18 | git branch --remote --contains | grep origin/main
19 | - name: Get version information from tag
20 | id: get_version
21 | run: |
22 | $version="${{github.ref_name}}".TrimStart("v")
23 | "version-without-v=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
24 | - name: Pack
25 | run: dotnet pack src\Plugin.Maui.UITestHelpers.sln -c Release -p:PackageVersion=${{ steps.get_version.outputs.version-without-v }}
26 | - name: Push
27 | run: |
28 | dotnet nuget push src\Plugin.Maui.UITestHelpers.Core\bin\Release\Plugin.Maui.UITestHelpers.Core.${{ steps.get_version.outputs.version-without-v }}.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
29 | dotnet nuget push src\Plugin.Maui.UITestHelpers.Appium\bin\Release\Plugin.Maui.UITestHelpers.Appium.${{ steps.get_version.outputs.version-without-v }}.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
30 | dotnet nuget push src\Plugin.Maui.UITestHelpers.NUnit\bin\Release\Plugin.Maui.UITestHelpers.NUnit.${{ steps.get_version.outputs.version-without-v }}.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
31 | env:
32 | GITHUB_TOKEN: ${{ secrets.NUGET_API_KEY }}
33 |
--------------------------------------------------------------------------------
/.github/workflows/ui-test-android.yml:
--------------------------------------------------------------------------------
1 | name: Run UI Tests Android
2 |
3 | on:
4 | push:
5 | branches: [ "main" ]
6 | paths-ignore:
7 | - "**.md"
8 | pull_request:
9 | branches: [ "main" ]
10 |
11 | env:
12 | BUILD_CONFIGURATION: Release
13 | CSPROJ_TO_BUILD: samples/Plugin.Maui.UITestHelpers.Sample/Plugin.Maui.UITestHelpers.Sample.csproj
14 | APP_TO_TEST: samples/Plugin.Maui.UITestHelpers.Sample/bin/Release/net8.0-android/com.companyname.uitesthelperssample-Signed.apk
15 | CSPROJ_TO_TEST: samples/UITests.Android/UITests.Android.csproj
16 | APP_ID: com.companyname.uitesthelperssample
17 | TARGET_FRAMEWORK: net8.0-android
18 | TEST_EMULATOR_NAME: UITestEmu
19 | ANDROID_EMULATOR_IMAGE: system-images;android-33;default;x86_64
20 | SCREENCAPTURE_FOLDER: samples/UITests.Android/bin/Debug/net8.0
21 | ARTIFACTS_PATH: ${{ github.workspace }}/output
22 |
23 | jobs:
24 | ui-test-android:
25 |
26 | runs-on: macos-13
27 |
28 | steps:
29 | - uses: actions/checkout@v4
30 |
31 | - name: Restore Tools
32 | run: dotnet tool restore
33 |
34 | - name: Restore Workload
35 | run: dotnet workload restore --project ${{ env.CSPROJ_TO_BUILD }}
36 |
37 | - name: Publish APK
38 | run: dotnet publish ${{ env.CSPROJ_TO_BUILD }} -f ${{ env.TARGET_FRAMEWORK }}
39 |
40 | - name: Boot Android emulator
41 | run: |
42 | dotnet android sdk install --package '${{ env.ANDROID_EMULATOR_IMAGE }}'
43 | dotnet android avd create --name ${{ env.TEST_EMULATOR_NAME }} --sdk '${{ env.ANDROID_EMULATOR_IMAGE }}' --force
44 | dotnet android avd start --name ${{ env.TEST_EMULATOR_NAME }} --wait-boot --gpu guest --no-snapshot --no-audio --no-boot-anim --no-window
45 | dotnet android device list
46 |
47 | - name: Install App
48 | run: dotnet android device install --package ${{ env.APP_TO_TEST }}
49 |
50 | - name: Install Appium
51 | run: |
52 | npm install -g appium
53 | appium driver install uiautomator2
54 |
55 | - name: Run UI Tests
56 | run: dotnet test ${{ env.CSPROJ_TO_TEST }} --environment APPIUM_LOG_FILE=${{ env.ARTIFACTS_PATH }}/appium-logs/appium.log --environment APPID="${{ env.APP_ID }}"
57 |
58 | - name: Publish Artifacts
59 | uses: actions/upload-artifact@v4
60 | if: always()
61 | with:
62 | name: logs-and-screenshots
63 | path: |
64 | ${{ env.ARTIFACTS_PATH }}/**/*.*
65 | ${{ env.SCREENCAPTURE_FOLDER }}/*.png
--------------------------------------------------------------------------------
/.github/workflows/ui-test-ios.yml:
--------------------------------------------------------------------------------
1 | name: Run UI Tests iOS
2 |
3 | on:
4 | push:
5 | branches: [ "main" ]
6 | paths-ignore:
7 | - "**.md"
8 | pull_request:
9 | branches: [ "main" ]
10 |
11 | env:
12 | # Release builds don't run on the Simulator
13 | BUILD_CONFIGURATION: Debug
14 | CSPROJ_TO_BUILD: samples/Plugin.Maui.UITestHelpers.Sample/Plugin.Maui.UITestHelpers.Sample.csproj
15 | APP_TO_TEST: samples/Plugin.Maui.UITestHelpers.Sample/bin/Debug/net8.0-ios/iossimulator-arm64/Plugin.Maui.UITestHelpers.Sample.app
16 | CSPROJ_TO_TEST: samples/UITests.iOS/UITests.iOS.csproj
17 | APP_ID: com.companyname.uitesthelperssample
18 | TARGET_FRAMEWORK: net8.0-ios
19 | XCODE_VERSION: 16.0
20 | TEST_SIM_NAME: UITestSim
21 | SCREENCAPTURE_FOLDER: samples/UITests.iOS/bin/Debug/net8.0
22 | ARTIFACTS_PATH: ${{ github.workspace }}/output
23 |
24 | jobs:
25 | ui-test-ios:
26 |
27 | runs-on: macos-14
28 |
29 | steps:
30 | - uses: actions/checkout@v4
31 |
32 | - name: Select Xcode version
33 | run: sudo xcode-select -s '/Applications/Xcode_${{ env.XCODE_VERSION }}.app/Contents/Developer'
34 |
35 | - name: Restore Workload
36 | run: dotnet workload restore --project ${{ env.CSPROJ_TO_BUILD }}
37 |
38 | - name: Build App
39 | run: dotnet build ${{ env.CSPROJ_TO_BUILD }} -f ${{ env.TARGET_FRAMEWORK }} -c ${{ env.BUILD_CONFIGURATION }}
40 |
41 | - name: Install Appium
42 | run: |
43 | npm install -g appium
44 | appium driver install xcuitest
45 |
46 | - name: Create iOS Simulator
47 | # This creates a iPhone 15 Pro Simulator with iOS 17.5
48 | run: |
49 | #xcodes runtimes install "iOS 17.5"
50 | #simudid=$(xcrun simctl create ${{ env.TEST_SIM_NAME }} com.apple.CoreSimulator.SimDeviceType.iPhone-15-Pro com.apple.CoreSimulator.SimRuntime.iOS-17-5)
51 | simudid=$(xcrun simctl create ${{ env.TEST_SIM_NAME }} com.apple.CoreSimulator.SimDeviceType.iPhone-15-Pro)
52 | echo "SIM_UDID=$(echo $simudid)" >> $GITHUB_ENV
53 | echo "Created Simulator UDID: $simudid"
54 |
55 | - name: Install App
56 | run: |
57 | xcrun simctl boot "${{ env.SIM_UDID }}"
58 | xcrun simctl install "${{ env.SIM_UDID }}" "${{ env.APP_TO_TEST }}"
59 |
60 | - name: Run UI Tests
61 | # We're passing on the values we used to create the Simulator with to the test project to find the correct one
62 | run: |
63 | dotnet test ${{ env.CSPROJ_TO_TEST }} --environment SIMNAME="${{ env.TEST_SIM_NAME }}" --environment SIMID="${{ env.SIM_UDID }}" \
64 | --environment APPIUM_LOG_FILE=${{ env.ARTIFACTS_PATH }}/appium-logs/appium.log --environment APPID="${{ env.APP_ID }}"
65 |
66 | - name: Publish Artifacts
67 | uses: actions/upload-artifact@v4
68 | if: always()
69 | with:
70 | name: logs-and-screenshots
71 | path: |
72 | ${{ env.ARTIFACTS_PATH }}/**/*.*
73 | ${{ env.SCREENCAPTURE_FOLDER }}/*.png
74 |
--------------------------------------------------------------------------------
/.github/workflows/ui-test-macos.yml:
--------------------------------------------------------------------------------
1 | name: Run UI Tests macOS
2 |
3 | on:
4 | push:
5 | branches: [ "main" ]
6 | paths-ignore:
7 | - "**.md"
8 | pull_request:
9 | branches: [ "main" ]
10 |
11 | env:
12 | BUILD_CONFIGURATION: Release
13 | CSPROJ_TO_BUILD: samples/Plugin.Maui.UITestHelpers.Sample/Plugin.Maui.UITestHelpers.Sample.csproj
14 | APP_TO_TEST: samples/Plugin.Maui.UITestHelpers.Sample/bin/Release/net8.0-maccatalyst/maccatalyst-arm64/Plugin.Maui.UITestHelpers.Sample.app
15 | CSPROJ_TO_TEST: samples/UITests.macOS/UITests.macOS.csproj
16 | APP_ID: com.companyname.uitesthelperssample
17 | TARGET_FRAMEWORK: net8.0-maccatalyst
18 | XCODE_VERSION: 15.2
19 | SCREENCAPTURE_FOLDER: samples/UITests.macOS/bin/Debug/net8.0
20 | ARTIFACTS_PATH: ${{ github.workspace }}/output
21 |
22 | jobs:
23 | ui-test-macos:
24 |
25 | runs-on: macos-14
26 |
27 | steps:
28 | - uses: actions/checkout@v4
29 |
30 | - name: Select Xcode version
31 | run: sudo xcode-select -s '/Applications/Xcode_${{ env.XCODE_VERSION }}.app/Contents/Developer'
32 |
33 | - name: Restore Workload
34 | run: dotnet workload restore --project ${{ env.CSPROJ_TO_BUILD }}
35 |
36 | - name: Build App
37 | run: dotnet build ${{ env.CSPROJ_TO_BUILD }} -f ${{ env.TARGET_FRAMEWORK }} -c ${{ env.BUILD_CONFIGURATION }}
38 |
39 | - name: Install Appium
40 | run: |
41 | npm install -g appium
42 | appium driver install mac2
43 |
44 | - name: Install App
45 | # Deploy the app by running it on this Mac
46 | run: dotnet build ${{ env.CSPROJ_TO_BUILD }} -t:Run -f ${{ env.TARGET_FRAMEWORK }} -c ${{ env.BUILD_CONFIGURATION }}
47 |
48 | - name: Run UI Tests
49 | run: |
50 | dotnet test ${{ env.CSPROJ_TO_TEST }} --environment APPIUM_LOG_FILE=${{ env.ARTIFACTS_PATH }}/appium-logs/appium.log --environment APPID="${{ env.APP_ID }}"
51 |
52 | - name: Publish Artifacts
53 | uses: actions/upload-artifact@v4
54 | if: always()
55 | with:
56 | name: logs-and-screenshots
57 | path: |
58 | ${{ env.ARTIFACTS_PATH }}/**/*.*
59 | ${{ env.SCREENCAPTURE_FOLDER }}/*.png
60 |
--------------------------------------------------------------------------------
/.github/workflows/ui-test-windows.yml:
--------------------------------------------------------------------------------
1 | name: Run UI Tests Windows
2 |
3 | on:
4 | push:
5 | branches: [ "main" ]
6 | paths-ignore:
7 | - "**.md"
8 | pull_request:
9 | branches: [ "main" ]
10 |
11 | env:
12 | BUILD_CONFIGURATION: Release
13 | CSPROJ_TO_BUILD: samples/Plugin.Maui.UITestHelpers.Sample/Plugin.Maui.UITestHelpers.Sample.csproj
14 | APP_TO_TEST: samples/Plugin.Maui.UITestHelpers.Sample/bin/Release/net8.0-windows10.0.19041.0/win10-x64/Plugin.Maui.UITestHelpers.Sample.exe
15 | CSPROJ_TO_TEST: samples/UITests.Windows/UITests.Windows.csproj
16 | TARGET_FRAMEWORK: net8.0-windows10.0.19041.0
17 | SCREENCAPTURE_FOLDER: samples/UITests.Windows/bin/Debug/net8.0
18 | ARTIFACTS_PATH: ${{ github.workspace }}/output
19 |
20 | jobs:
21 | ui-test-windows:
22 |
23 | runs-on: windows-latest
24 |
25 | steps:
26 | - uses: actions/checkout@v4
27 |
28 | - name: Build App
29 | run: dotnet build ${{ env.CSPROJ_TO_BUILD }} -f ${{ env.TARGET_FRAMEWORK }} -c ${{ env.BUILD_CONFIGURATION }}
30 |
31 | - name: Install Appium
32 | run: |
33 | npm install -g appium
34 | appium driver install --source=npm appium-windows-driver
35 |
36 | - name: Run UI Tests
37 | run: |
38 | # Set environment variable separately because of https://github.com/dotnet/sdk/issues/40848
39 | $absolutePath = ("${{ env.APP_TO_TEST }}" | Resolve-Path).Path
40 | $env:APPID = $absolutePath
41 | dotnet test ${{ env.CSPROJ_TO_TEST }} --environment APPIUM_LOG_FILE=${{ env.ARTIFACTS_PATH }}/appium-logs/appium.log
42 |
43 | - name: Publish Artifacts
44 | uses: actions/upload-artifact@v4
45 | if: always()
46 | with:
47 | name: logs-and-screenshots
48 | path: |
49 | ${{ env.ARTIFACTS_PATH }}/**/*.*
50 | ${{ env.SCREENCAPTURE_FOLDER }}/*.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Ll]og/
33 | [Ll]ogs/
34 |
35 | # Visual Studio 2015/2017 cache/options directory
36 | .vs/
37 | # Uncomment if you have tasks that create the project's static files in wwwroot
38 | #wwwroot/
39 |
40 | # Visual Studio 2017 auto generated files
41 | Generated\ Files/
42 |
43 | # MSTest test Results
44 | [Tt]est[Rr]esult*/
45 | [Bb]uild[Ll]og.*
46 |
47 | # NUnit
48 | *.VisualState.xml
49 | TestResult.xml
50 | nunit-*.xml
51 |
52 | # Build Results of an ATL Project
53 | [Dd]ebugPS/
54 | [Rr]eleasePS/
55 | dlldata.c
56 |
57 | # Benchmark Results
58 | BenchmarkDotNet.Artifacts/
59 |
60 | # .NET Core
61 | project.lock.json
62 | project.fragment.lock.json
63 | artifacts/
64 |
65 | # ASP.NET Scaffolding
66 | ScaffoldingReadMe.txt
67 |
68 | # StyleCop
69 | StyleCopReport.xml
70 |
71 | # Files built by Visual Studio
72 | *_i.c
73 | *_p.c
74 | *_h.h
75 | *.ilk
76 | *.meta
77 | *.obj
78 | *.iobj
79 | *.pch
80 | *.pdb
81 | *.ipdb
82 | *.pgc
83 | *.pgd
84 | *.rsp
85 | *.sbr
86 | *.tlb
87 | *.tli
88 | *.tlh
89 | *.tmp
90 | *.tmp_proj
91 | *_wpftmp.csproj
92 | *.log
93 | *.tlog
94 | *.vspscc
95 | *.vssscc
96 | .builds
97 | *.pidb
98 | *.svclog
99 | *.scc
100 |
101 | # Chutzpah Test files
102 | _Chutzpah*
103 |
104 | # Visual C++ cache files
105 | ipch/
106 | *.aps
107 | *.ncb
108 | *.opendb
109 | *.opensdf
110 | *.sdf
111 | *.cachefile
112 | *.VC.db
113 | *.VC.VC.opendb
114 |
115 | # Visual Studio profiler
116 | *.psess
117 | *.vsp
118 | *.vspx
119 | *.sap
120 |
121 | # Visual Studio Trace Files
122 | *.e2e
123 |
124 | # TFS 2012 Local Workspace
125 | $tf/
126 |
127 | # Guidance Automation Toolkit
128 | *.gpState
129 |
130 | # ReSharper is a .NET coding add-in
131 | _ReSharper*/
132 | *.[Rr]e[Ss]harper
133 | *.DotSettings.user
134 |
135 | # TeamCity is a build add-in
136 | _TeamCity*
137 |
138 | # DotCover is a Code Coverage Tool
139 | *.dotCover
140 |
141 | # AxoCover is a Code Coverage Tool
142 | .axoCover/*
143 | !.axoCover/settings.json
144 |
145 | # Coverlet is a free, cross platform Code Coverage Tool
146 | coverage*.json
147 | coverage*.xml
148 | coverage*.info
149 |
150 | # Visual Studio code coverage results
151 | *.coverage
152 | *.coveragexml
153 |
154 | # NCrunch
155 | _NCrunch_*
156 | .*crunch*.local.xml
157 | nCrunchTemp_*
158 |
159 | # MightyMoose
160 | *.mm.*
161 | AutoTest.Net/
162 |
163 | # Web workbench (sass)
164 | .sass-cache/
165 |
166 | # Installshield output folder
167 | [Ee]xpress/
168 |
169 | # DocProject is a documentation generator add-in
170 | DocProject/buildhelp/
171 | DocProject/Help/*.HxT
172 | DocProject/Help/*.HxC
173 | DocProject/Help/*.hhc
174 | DocProject/Help/*.hhk
175 | DocProject/Help/*.hhp
176 | DocProject/Help/Html2
177 | DocProject/Help/html
178 |
179 | # Click-Once directory
180 | publish/
181 |
182 | # Publish Web Output
183 | *.[Pp]ublish.xml
184 | *.azurePubxml
185 | # Note: Comment the next line if you want to checkin your web deploy settings,
186 | # but database connection strings (with potential passwords) will be unencrypted
187 | *.pubxml
188 | *.publishproj
189 |
190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
191 | # checkin your Azure Web App publish settings, but sensitive information contained
192 | # in these scripts will be unencrypted
193 | PublishScripts/
194 |
195 | # NuGet Packages
196 | *.nupkg
197 | # NuGet Symbol Packages
198 | *.snupkg
199 | # The packages folder can be ignored because of Package Restore
200 | **/[Pp]ackages/*
201 | # except build/, which is used as an MSBuild target.
202 | !**/[Pp]ackages/build/
203 | # Uncomment if necessary however generally it will be regenerated when needed
204 | #!**/[Pp]ackages/repositories.config
205 | # NuGet v3's project.json files produces more ignorable files
206 | *.nuget.props
207 | *.nuget.targets
208 |
209 | # Microsoft Azure Build Output
210 | csx/
211 | *.build.csdef
212 |
213 | # Microsoft Azure Emulator
214 | ecf/
215 | rcf/
216 |
217 | # Windows Store app package directories and files
218 | AppPackages/
219 | BundleArtifacts/
220 | Package.StoreAssociation.xml
221 | _pkginfo.txt
222 | *.appx
223 | *.appxbundle
224 | *.appxupload
225 |
226 | # Visual Studio cache files
227 | # files ending in .cache can be ignored
228 | *.[Cc]ache
229 | # but keep track of directories ending in .cache
230 | !?*.[Cc]ache/
231 |
232 | # Others
233 | ClientBin/
234 | ~$*
235 | *~
236 | *.dbmdl
237 | *.dbproj.schemaview
238 | *.jfm
239 | *.pfx
240 | *.publishsettings
241 | orleans.codegen.cs
242 |
243 | # Including strong name files can present a security risk
244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
245 | #*.snk
246 |
247 | # Since there are multiple workflows, uncomment next line to ignore bower_components
248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
249 | #bower_components/
250 |
251 | # RIA/Silverlight projects
252 | Generated_Code/
253 |
254 | # Backup & report files from converting an old project file
255 | # to a newer Visual Studio version. Backup files are not needed,
256 | # because we have git ;-)
257 | _UpgradeReport_Files/
258 | Backup*/
259 | UpgradeLog*.XML
260 | UpgradeLog*.htm
261 | ServiceFabricBackup/
262 | *.rptproj.bak
263 |
264 | # SQL Server files
265 | *.mdf
266 | *.ldf
267 | *.ndf
268 |
269 | # Business Intelligence projects
270 | *.rdl.data
271 | *.bim.layout
272 | *.bim_*.settings
273 | *.rptproj.rsuser
274 | *- [Bb]ackup.rdl
275 | *- [Bb]ackup ([0-9]).rdl
276 | *- [Bb]ackup ([0-9][0-9]).rdl
277 |
278 | # Microsoft Fakes
279 | FakesAssemblies/
280 |
281 | # GhostDoc plugin setting file
282 | *.GhostDoc.xml
283 |
284 | # Node.js Tools for Visual Studio
285 | .ntvs_analysis.dat
286 | node_modules/
287 |
288 | # Visual Studio 6 build log
289 | *.plg
290 |
291 | # Visual Studio 6 workspace options file
292 | *.opt
293 |
294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
295 | *.vbw
296 |
297 | # Visual Studio 6 auto-generated project file (contains which files were open etc.)
298 | *.vbp
299 |
300 | # Visual Studio 6 workspace and project file (working project files containing files to include in project)
301 | *.dsw
302 | *.dsp
303 |
304 | # Visual Studio 6 technical files
305 | *.ncb
306 | *.aps
307 |
308 | # Visual Studio LightSwitch build output
309 | **/*.HTMLClient/GeneratedArtifacts
310 | **/*.DesktopClient/GeneratedArtifacts
311 | **/*.DesktopClient/ModelManifest.xml
312 | **/*.Server/GeneratedArtifacts
313 | **/*.Server/ModelManifest.xml
314 | _Pvt_Extensions
315 |
316 | # Paket dependency manager
317 | .paket/paket.exe
318 | paket-files/
319 |
320 | # FAKE - F# Make
321 | .fake/
322 |
323 | # CodeRush personal settings
324 | .cr/personal
325 |
326 | # Python Tools for Visual Studio (PTVS)
327 | __pycache__/
328 | *.pyc
329 |
330 | # Cake - Uncomment if you are using it
331 | # tools/**
332 | # !tools/packages.config
333 |
334 | # Tabs Studio
335 | *.tss
336 |
337 | # Telerik's JustMock configuration file
338 | *.jmconfig
339 |
340 | # BizTalk build output
341 | *.btp.cs
342 | *.btm.cs
343 | *.odx.cs
344 | *.xsd.cs
345 |
346 | # OpenCover UI analysis results
347 | OpenCover/
348 |
349 | # Azure Stream Analytics local run output
350 | ASALocalRun/
351 |
352 | # MSBuild Binary and Structured Log
353 | *.binlog
354 |
355 | # NVidia Nsight GPU debugger configuration file
356 | *.nvuser
357 |
358 | # MFractors (Xamarin productivity tool) working folder
359 | .mfractor/
360 |
361 | # Local History for Visual Studio
362 | .localhistory/
363 |
364 | # Visual Studio History (VSHistory) files
365 | .vshistory/
366 |
367 | # BeatPulse healthcheck temp database
368 | healthchecksdb
369 |
370 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
371 | MigrationBackup/
372 |
373 | # Ionide (cross platform F# VS Code tools) working folder
374 | .ionide/
375 |
376 | # Fody - auto-generated XML schema
377 | FodyWeavers.xsd
378 |
379 | # VS Code files for those working on multiple tools
380 | .vscode/*
381 | !.vscode/settings.json
382 | !.vscode/tasks.json
383 | !.vscode/launch.json
384 | !.vscode/extensions.json
385 | *.code-workspace
386 |
387 | # Local History for Visual Studio Code
388 | .history/
389 |
390 | # Windows Installer files from build outputs
391 | *.cab
392 | *.msi
393 | *.msix
394 | *.msm
395 | *.msp
396 |
397 | # JetBrains Rider
398 | *.sln.iml
399 | .DS_Store
400 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 Gerald Versluis
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 | # Plugin.Maui.UITestHelpers
3 |
4 | `Plugin.Maui.UITestHelpers` provides a set of helpers to support UI testing your .NET MAUI app with Appium and migration from Xamarin.UITest to Appium. It consists of three packages, see below for more information.
5 |
6 | The set of helpers are extracted from the .NET MAUI codebase ([here](https://github.com/dotnet/maui/tree/main/src/TestUtils/src), the folders prefixed UITest) this code can help with writing UI tests with Appium and/or transition your existing Xamarin.UITest tests to Appium.
7 |
8 | > [!WARNING]
9 | > At this time this project is not officially supported and experimental.
10 | > Feel free to let us know your feedback and provide pull requests to make it even better.
11 | > There is no guarantee this will become something more official.
12 |
13 | But if you like what you see and help make it better... It might!
14 |
15 | ## Install Plugin
16 |
17 | This project consists of three packages. please find the details below. All packages are available on NuGet.
18 |
19 | | Package Name | Description | NuGet Package |
20 | |----------|------------|---------------|
21 | | Plugin.Maui.UITestHelpers.Core | Shared, core types that are used across the different projects | [](https://www.nuget.org/packages/Plugin.Maui.UITestHelpers.Core/1.0.0-preview1) |
22 | | Plugin.Maui.UITestHelpers.Appium | This package contains code specific to UI testing with Appium. It's filled with helpers that will make writing UI tests easier, as well as methods that (mostly) mimic Xamarin.UITest to make transitioning your current UI tests easier | [](https://www.nuget.org/packages/Plugin.Maui.UITestHelpers.Appium/1.0.0-preview1) |
23 | | Plugin.Maui.UITestHelpers.NUnit | This package contains helpers that will make it easier to write UI tests based on NUnit | [](https://www.nuget.org/packages/Plugin.Maui.UITestHelpers.NUnit/1.0.0-preview1) |
24 |
25 | Install with the dotnet CLI, for example: `dotnet add package Plugin.Maui.UITestHelpers.Appium`, or through the NuGet Package Manager in Visual Studio.
26 |
27 | ### Supported Platforms
28 |
29 | All platforms that are supported by the cross section of the support of Appium and .NET MAUI.
30 |
31 |
34 |
35 | # Acknowledgements
36 |
37 | This project could not have came to be without these projects and people, thank you! <3
38 |
39 | The original source was extracted from the [.NET MAUI codebase](https://github.com/dotnet/maui) so all credit goes out to that team, namely @sbanni, @mattleibow, @PureWeen, @MartyIX, @jsuarezruiz, @jfversluis and @rmarinho.
40 |
--------------------------------------------------------------------------------
/nuget.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jfversluis/Plugin.Maui.UITestHelpers/69d1bc2f692c71ae91c62f5f7f5031fe16824c13/nuget.png
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.0.31611.283
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Plugin.Maui.UITestHelpers.Sample", "Plugin.Maui.UITestHelpers.Sample\Plugin.Maui.UITestHelpers.Sample.csproj", "{490BB138-9606-4FFF-8AAD-841C5B1ED059}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UITests.Android", "UITests.Android\UITests.Android.csproj", "{6557E077-F81A-4D64-B3C4-A07BB1BD31D4}"
9 | EndProject
10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UITests.Shared", "UITests.Shared\UITests.Shared.csproj", "{DFD0E4D0-3519-4B55-8B31-CC7AF8106AAE}"
11 | EndProject
12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UITests.iOS", "UITests.iOS\UITests.iOS.csproj", "{2B36F0AB-6CF2-4EE8-8561-3A436304B744}"
13 | EndProject
14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UITests.macOS", "UITests.macOS\UITests.macOS.csproj", "{74557CDA-CB45-4719-9A7D-DE35B10B7345}"
15 | EndProject
16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UITests.Windows", "UITests.Windows\UITests.Windows.csproj", "{1A0A722B-2D19-42C6-A306-1417A283B244}"
17 | EndProject
18 | Global
19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
20 | Debug|Any CPU = Debug|Any CPU
21 | Release|Any CPU = Release|Any CPU
22 | EndGlobalSection
23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
24 | {490BB138-9606-4FFF-8AAD-841C5B1ED059}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25 | {490BB138-9606-4FFF-8AAD-841C5B1ED059}.Debug|Any CPU.Build.0 = Debug|Any CPU
26 | {490BB138-9606-4FFF-8AAD-841C5B1ED059}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
27 | {490BB138-9606-4FFF-8AAD-841C5B1ED059}.Release|Any CPU.ActiveCfg = Release|Any CPU
28 | {490BB138-9606-4FFF-8AAD-841C5B1ED059}.Release|Any CPU.Build.0 = Release|Any CPU
29 | {490BB138-9606-4FFF-8AAD-841C5B1ED059}.Release|Any CPU.Deploy.0 = Release|Any CPU
30 | {6557E077-F81A-4D64-B3C4-A07BB1BD31D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31 | {6557E077-F81A-4D64-B3C4-A07BB1BD31D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
32 | {6557E077-F81A-4D64-B3C4-A07BB1BD31D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
33 | {6557E077-F81A-4D64-B3C4-A07BB1BD31D4}.Release|Any CPU.Build.0 = Release|Any CPU
34 | {DFD0E4D0-3519-4B55-8B31-CC7AF8106AAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35 | {DFD0E4D0-3519-4B55-8B31-CC7AF8106AAE}.Debug|Any CPU.Build.0 = Debug|Any CPU
36 | {DFD0E4D0-3519-4B55-8B31-CC7AF8106AAE}.Release|Any CPU.ActiveCfg = Release|Any CPU
37 | {DFD0E4D0-3519-4B55-8B31-CC7AF8106AAE}.Release|Any CPU.Build.0 = Release|Any CPU
38 | {2B36F0AB-6CF2-4EE8-8561-3A436304B744}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39 | {2B36F0AB-6CF2-4EE8-8561-3A436304B744}.Debug|Any CPU.Build.0 = Debug|Any CPU
40 | {2B36F0AB-6CF2-4EE8-8561-3A436304B744}.Release|Any CPU.ActiveCfg = Release|Any CPU
41 | {2B36F0AB-6CF2-4EE8-8561-3A436304B744}.Release|Any CPU.Build.0 = Release|Any CPU
42 | {74557CDA-CB45-4719-9A7D-DE35B10B7345}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
43 | {74557CDA-CB45-4719-9A7D-DE35B10B7345}.Debug|Any CPU.Build.0 = Debug|Any CPU
44 | {74557CDA-CB45-4719-9A7D-DE35B10B7345}.Release|Any CPU.ActiveCfg = Release|Any CPU
45 | {74557CDA-CB45-4719-9A7D-DE35B10B7345}.Release|Any CPU.Build.0 = Release|Any CPU
46 | {1A0A722B-2D19-42C6-A306-1417A283B244}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
47 | {1A0A722B-2D19-42C6-A306-1417A283B244}.Debug|Any CPU.Build.0 = Debug|Any CPU
48 | {1A0A722B-2D19-42C6-A306-1417A283B244}.Release|Any CPU.ActiveCfg = Release|Any CPU
49 | {1A0A722B-2D19-42C6-A306-1417A283B244}.Release|Any CPU.Build.0 = Release|Any CPU
50 | EndGlobalSection
51 | GlobalSection(SolutionProperties) = preSolution
52 | HideSolutionNode = FALSE
53 | EndGlobalSection
54 | GlobalSection(ExtensibilityGlobals) = postSolution
55 | SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572}
56 | EndGlobalSection
57 | EndGlobal
58 |
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/App.xaml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/App.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Plugin.Maui.UITestHelpers.Sample;
2 |
3 | public partial class App : Application
4 | {
5 | public App()
6 | {
7 | InitializeComponent();
8 |
9 | MainPage = new AppShell();
10 | }
11 | }
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/AppShell.xaml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/AppShell.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Plugin.Maui.UITestHelpers.Sample;
2 |
3 | public partial class AppShell : Shell
4 | {
5 | public AppShell()
6 | {
7 | InitializeComponent();
8 | }
9 | }
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
15 |
16 |
20 |
21 |
26 |
27 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/MainPage.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Plugin.Maui.UITestHelpers.Sample;
2 |
3 | public partial class MainPage : ContentPage
4 | {
5 | int count = 0;
6 |
7 | public MainPage()
8 | {
9 | InitializeComponent();
10 | }
11 |
12 | private void OnCounterClicked(object sender, EventArgs e)
13 | {
14 | count++;
15 |
16 | if (count == 1)
17 | CounterBtn.Text = $"Clicked {count} time";
18 | else
19 | CounterBtn.Text = $"Clicked {count} times";
20 |
21 | SemanticScreenReader.Announce(CounterBtn.Text);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/MauiProgram.cs:
--------------------------------------------------------------------------------
1 | namespace Plugin.Maui.UITestHelpers.Sample;
2 |
3 | public static class MauiProgram
4 | {
5 | public static MauiApp CreateMauiApp()
6 | {
7 | var builder = MauiApp.CreateBuilder();
8 | builder
9 | .UseMauiApp()
10 | .ConfigureFonts(fonts =>
11 | {
12 | fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
13 | fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
14 | });
15 |
16 | return builder.Build();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Platforms/Android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Platforms/Android/MainActivity.cs:
--------------------------------------------------------------------------------
1 | using Android.App;
2 | using Android.Content.PM;
3 | using Android.OS;
4 | using Android.Runtime;
5 |
6 | namespace Plugin.Maui.UITestHelpers.Sample;
7 |
8 | [Register("com.companyname.uitesthelperssample.MainActivity")]
9 | [Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
10 | public class MainActivity : MauiAppCompatActivity
11 | {
12 | }
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Platforms/Android/MainApplication.cs:
--------------------------------------------------------------------------------
1 | using Android.App;
2 | using Android.Runtime;
3 |
4 | namespace Plugin.Maui.UITestHelpers.Sample;
5 |
6 | [Application]
7 | public class MainApplication : MauiApplication
8 | {
9 | public MainApplication(IntPtr handle, JniHandleOwnership ownership)
10 | : base(handle, ownership)
11 | {
12 | }
13 |
14 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
15 | }
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Platforms/Android/Resources/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #512BD4
4 | #2B0B98
5 | #2B0B98
6 |
7 |
8 |
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Platforms/MacCatalyst/AppDelegate.cs:
--------------------------------------------------------------------------------
1 | using Foundation;
2 |
3 | namespace Plugin.Maui.UITestHelpers.Sample;
4 |
5 | [Register("AppDelegate")]
6 | public class AppDelegate : MauiUIApplicationDelegate
7 | {
8 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
9 | }
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Platforms/MacCatalyst/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | UIDeviceFamily
6 |
7 | 1
8 | 2
9 |
10 | UIRequiredDeviceCapabilities
11 |
12 | arm64
13 |
14 | UISupportedInterfaceOrientations
15 |
16 | UIInterfaceOrientationPortrait
17 | UIInterfaceOrientationLandscapeLeft
18 | UIInterfaceOrientationLandscapeRight
19 |
20 | UISupportedInterfaceOrientations~ipad
21 |
22 | UIInterfaceOrientationPortrait
23 | UIInterfaceOrientationPortraitUpsideDown
24 | UIInterfaceOrientationLandscapeLeft
25 | UIInterfaceOrientationLandscapeRight
26 |
27 | XSAppIconAssets
28 | Assets.xcassets/appicon.appiconset
29 |
30 |
31 |
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Platforms/MacCatalyst/Program.cs:
--------------------------------------------------------------------------------
1 | using ObjCRuntime;
2 | using UIKit;
3 |
4 | namespace Plugin.Maui.UITestHelpers.Sample;
5 |
6 | public class Program
7 | {
8 | // This is the main entry point of the application.
9 | static void Main(string[] args)
10 | {
11 | // if you want to use a different Application Delegate class from "AppDelegate"
12 | // you can specify it here.
13 | UIApplication.Main(args, null, typeof(AppDelegate));
14 | }
15 | }
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Platforms/Tizen/Main.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.Maui;
3 | using Microsoft.Maui.Hosting;
4 |
5 | namespace Plugin.Maui.UITestHelpers.Sample;
6 |
7 | class Program : MauiApplication
8 | {
9 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
10 |
11 | static void Main(string[] args)
12 | {
13 | var app = new Program();
14 | app.Run(args);
15 | }
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Platforms/Tizen/tizen-manifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | maui-appicon-placeholder
7 |
8 |
9 |
10 |
11 | http://tizen.org/privilege/internet
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Platforms/Windows/App.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Platforms/Windows/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.UI.Xaml;
2 |
3 | // To learn more about WinUI, the WinUI project structure,
4 | // and more about our project templates, see: http://aka.ms/winui-project-info.
5 |
6 | namespace Plugin.Maui.UITestHelpers.Sample.WinUI;
7 |
8 | ///
9 | /// Provides application-specific behavior to supplement the default Application class.
10 | ///
11 | public partial class App : MauiWinUIApplication
12 | {
13 | ///
14 | /// Initializes the singleton application object. This is the first line of authored code
15 | /// executed, and as such is the logical equivalent of main() or WinMain().
16 | ///
17 | public App()
18 | {
19 | this.InitializeComponent();
20 | }
21 |
22 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
23 | }
24 |
25 |
26 |
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Platforms/Windows/Package.appxmanifest:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
12 | $placeholder$
13 | User Name
14 | $placeholder$.png
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Platforms/Windows/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
11 | true/PM
12 | PerMonitorV2, PerMonitor
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Platforms/iOS/AppDelegate.cs:
--------------------------------------------------------------------------------
1 | using Foundation;
2 |
3 | namespace Plugin.Maui.UITestHelpers.Sample;
4 |
5 | [Register("AppDelegate")]
6 | public class AppDelegate : MauiUIApplicationDelegate
7 | {
8 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
9 | }
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Platforms/iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | LSRequiresIPhoneOS
6 |
7 | UIDeviceFamily
8 |
9 | 1
10 | 2
11 |
12 | UIRequiredDeviceCapabilities
13 |
14 | arm64
15 |
16 | UISupportedInterfaceOrientations
17 |
18 | UIInterfaceOrientationPortrait
19 | UIInterfaceOrientationLandscapeLeft
20 | UIInterfaceOrientationLandscapeRight
21 |
22 | UISupportedInterfaceOrientations~ipad
23 |
24 | UIInterfaceOrientationPortrait
25 | UIInterfaceOrientationPortraitUpsideDown
26 | UIInterfaceOrientationLandscapeLeft
27 | UIInterfaceOrientationLandscapeRight
28 |
29 | XSAppIconAssets
30 | Assets.xcassets/appicon.appiconset
31 |
32 |
33 |
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Platforms/iOS/Program.cs:
--------------------------------------------------------------------------------
1 | using ObjCRuntime;
2 | using UIKit;
3 |
4 | namespace Plugin.Maui.UITestHelpers.Sample;
5 |
6 | public class Program
7 | {
8 | // This is the main entry point of the application.
9 | static void Main(string[] args)
10 | {
11 | // if you want to use a different Application Delegate class from "AppDelegate"
12 | // you can specify it here.
13 | UIApplication.Main(args, null, typeof(AppDelegate));
14 | }
15 | }
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Plugin.Maui.UITestHelpers.Sample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0-android;net8.0-ios;net8.0-maccatalyst
5 | $(TargetFrameworks);net8.0-windows10.0.19041.0
6 |
7 |
8 | Exe
9 | Plugin.Maui.UITestHelpers.Sample
10 | true
11 | true
12 | enable
13 |
14 |
15 | Plugin.Maui.UITestHelpers.Sample
16 |
17 |
18 | com.companyname.uitesthelperssample
19 |
20 |
21 | 1.0
22 | 1
23 |
24 | 14.2
25 | 14.0
26 | 21.0
27 | 10.0.17763.0
28 | 10.0.17763.0
29 | 6.5
30 |
31 |
32 |
33 | None
34 | false
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "Windows Machine": {
4 | "commandName": "MsixPackage",
5 | "nativeDebugging": false
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Resources/AppIcon/appicon.svg:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Resources/AppIcon/appiconfg.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Resources/Fonts/OpenSans-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jfversluis/Plugin.Maui.UITestHelpers/69d1bc2f692c71ae91c62f5f7f5031fe16824c13/samples/Plugin.Maui.UITestHelpers.Sample/Resources/Fonts/OpenSans-Regular.ttf
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Resources/Fonts/OpenSans-Semibold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jfversluis/Plugin.Maui.UITestHelpers/69d1bc2f692c71ae91c62f5f7f5031fe16824c13/samples/Plugin.Maui.UITestHelpers.Sample/Resources/Fonts/OpenSans-Semibold.ttf
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Resources/Images/dotnet_bot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jfversluis/Plugin.Maui.UITestHelpers/69d1bc2f692c71ae91c62f5f7f5031fe16824c13/samples/Plugin.Maui.UITestHelpers.Sample/Resources/Images/dotnet_bot.png
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Resources/Raw/AboutAssets.txt:
--------------------------------------------------------------------------------
1 | Any raw assets you want to be deployed with your application can be placed in
2 | this directory (and child directories). Deployment of the asset to your application
3 | is automatically handled by the following `MauiAsset` Build Action within your `.csproj`.
4 |
5 |
6 |
7 | These files will be deployed with you package and will be accessible using Essentials:
8 |
9 | async Task LoadMauiAsset()
10 | {
11 | using var stream = await FileSystem.OpenAppPackageFileAsync("AboutAssets.txt");
12 | using var reader = new StreamReader(stream);
13 |
14 | var contents = reader.ReadToEnd();
15 | }
16 |
17 |
18 |
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Resources/Splash/splash.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/samples/Plugin.Maui.UITestHelpers.Sample/Resources/Styles/Colors.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 | #512BD4
10 | #ac99ea
11 | #242424
12 | #DFD8F7
13 | #9880e5
14 | #2B0B98
15 |
16 | White
17 | Black
18 | #D600AA
19 | #190649
20 | #1f1f1f
21 |
22 | #E1E1E1
23 | #C8C8C8
24 | #ACACAC
25 | #919191
26 | #6E6E6E
27 | #404040
28 | #212121
29 | #141414
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/samples/UITests.Android/UITests.Android.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | enable
6 | enable
7 | true
8 | UITests
9 |
10 |
11 |
12 | $(DefineConstants);ANDROID
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/samples/UITests.Shared/AssemblyTestFixture.cs:
--------------------------------------------------------------------------------
1 | using Plugin.Maui.UITestHelpers.Appium;
2 |
3 | // SetupFixture runs once for all tests under the same namespace, if placed outside the namespace it will run once for all tests in the assembly
4 | public class AssemblySetupFixture : UITestContextSetupFixture
5 | {
6 | AppiumServerContext? _appiumServerContext;
7 |
8 | public override void Initialize()
9 | {
10 | _appiumServerContext = new AppiumServerContext();
11 | _appiumServerContext.CreateAndStartServer();
12 | _serverContext = _appiumServerContext;
13 | }
14 | }
--------------------------------------------------------------------------------
/samples/UITests.Shared/BaseTest.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework;
2 | using Plugin.Maui.UITestHelpers.Core;
3 | using System.Diagnostics;
4 | using UITest.Appium.NUnit;
5 |
6 | namespace UITests.Shared;
7 |
8 | #if ANDROID
9 | [TestFixture(TestDevice.Android)]
10 | #elif IOS
11 | [TestFixture(TestDevice.iOS)]
12 | #elif MACOS
13 | [TestFixture(TestDevice.Mac)]
14 | #elif WINDOWS
15 | [TestFixture(TestDevice.Windows)]
16 | #endif
17 | public abstract class BaseTest : UITestBase
18 | {
19 | public BaseTest(TestDevice testDevice) : base(testDevice)
20 | {
21 | }
22 |
23 | public override IConfig GetTestConfig()
24 | {
25 | var config = new Config();
26 |
27 | var appIdentifierKey = "AppId";
28 |
29 | // Note: an app with this ID has to be deployed to the emulator/device you want to run it on
30 | var appIdentifier = "com.companyname.uitesthelperssample";
31 |
32 | if (_testDevice == TestDevice.Windows)
33 | {
34 | appIdentifierKey = "AppPath";
35 |
36 | // Note: a release build has to be done and the path to this .exe file should exist. Tweak this path if necessary
37 | var absolutePath = Path.GetFullPath("..\\..\\..\\..\\Plugin.Maui.UITestHelpers.Sample\\bin\\Release\\net8.0-windows10.0.19041.0\\win10-x64\\Plugin.Maui.UITestHelpers.Sample.exe");
38 | appIdentifier = absolutePath;
39 | }
40 |
41 | // If the app ID is provided through an environment variable, like through CI, use that instead
42 | if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("APPID")))
43 | {
44 | appIdentifier = Environment.GetEnvironmentVariable("APPID");
45 | }
46 |
47 | config.SetProperty(appIdentifierKey, appIdentifier);
48 |
49 | if (_testDevice == TestDevice.iOS)
50 | {
51 | // Note: this is passed down from the GitHub Action. If nothing is set, fall back to a default value below
52 | if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("SIMID")))
53 | {
54 | config.SetProperty("Udid", Environment.GetEnvironmentVariable("SIMID"));
55 | }
56 | else
57 | {
58 | config.SetProperty("DeviceName", "iPhone 15 Pro");
59 | config.SetProperty("PlatformVersion", "17.2");
60 | }
61 | }
62 |
63 | return config;
64 | }
65 | }
--------------------------------------------------------------------------------
/samples/UITests.Shared/MainPageTests.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework;
2 | using Plugin.Maui.UITestHelpers.Core;
3 | using Plugin.Maui.UITestHelpers.Appium;
4 |
5 | namespace UITests.Shared;
6 |
7 | public class MainPageTests : BaseTest
8 | {
9 | public MainPageTests(TestDevice testDevice) : base(testDevice)
10 | {
11 | }
12 |
13 | [Test]
14 | public void AppLaunches()
15 | {
16 | App.Screenshot($"{nameof(AppLaunches)}.png");
17 | }
18 |
19 | [Test]
20 | public void ClickCounterTest()
21 | {
22 | const string elementId = "CounterBtn";
23 |
24 | // Arrange
25 | // Find elements with the value of the AutomationId property
26 | var element = App.FindElement(elementId);
27 | App.WaitForElement(elementId);
28 |
29 | // Act
30 | element.Click();
31 | Task.Delay(500).Wait(); // Wait for the click to register and show up on the screenshot
32 |
33 | // Assert
34 | App.Screenshot($"{nameof(ClickCounterTest)}.png");
35 | Assert.That(element.GetText(), Is.EqualTo("Clicked 1 time"));
36 | }
37 | }
--------------------------------------------------------------------------------
/samples/UITests.Shared/UITests.Shared.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | False
6 | False
7 | UITests
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/samples/UITests.Windows/UITests.Windows.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | enable
6 | enable
7 | true
8 | UITests
9 |
10 |
11 |
12 | $(DefineConstants);WINDOWS
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/samples/UITests.iOS/UITests.iOS.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | enable
6 | enable
7 | true
8 | UITests
9 |
10 |
11 |
12 | $(DefineConstants);IOS
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/samples/UITests.macOS/UITests.macOS.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | enable
6 | enable
7 | true
8 | UITests
9 |
10 |
11 |
12 | $(DefineConstants);MACOS
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/Plugin.Maui.UITestHelpers.Appium/Actions/AppiumAndroidAlertActions.cs:
--------------------------------------------------------------------------------
1 | using OpenQA.Selenium.Appium;
2 | using Plugin.Maui.UITestHelpers.Core;
3 |
4 | namespace Plugin.Maui.UITestHelpers.Appium;
5 |
6 | public class AppiumAndroidAlertActions : ICommandExecutionGroup
7 | {
8 | const string GetAlertsCommand = "getAlerts";
9 | const string GetAlertButtonsCommand = "getAlertButtons";
10 | const string GetAlertTextCommand = "getAlertText";
11 |
12 | readonly List _commands = new()
13 | {
14 | GetAlertsCommand,
15 | GetAlertButtonsCommand,
16 | GetAlertTextCommand,
17 | };
18 | readonly AppiumApp _appiumApp;
19 |
20 | public AppiumAndroidAlertActions(AppiumApp appiumApp)
21 | {
22 | _appiumApp = appiumApp;
23 | }
24 |
25 | public bool IsCommandSupported(string commandName)
26 | {
27 | return _commands.Contains(commandName, StringComparer.OrdinalIgnoreCase);
28 | }
29 |
30 | public CommandResponse Execute(string commandName, IDictionary parameters)
31 | {
32 | return commandName switch
33 | {
34 | GetAlertsCommand => GetAlerts(parameters),
35 | GetAlertButtonsCommand => GetAlertButtons(parameters),
36 | GetAlertTextCommand => GetAlertText(parameters),
37 | _ => CommandResponse.FailedEmptyResponse,
38 | };
39 | }
40 |
41 | CommandResponse GetAlerts(IDictionary parameters)
42 | {
43 | var alerts = _appiumApp.Query.ById("parentPanel");
44 |
45 | if (alerts is null || alerts.Count == 0)
46 | return CommandResponse.FailedEmptyResponse;
47 |
48 | return new CommandResponse(alerts, CommandResponseResult.Success);
49 | }
50 |
51 | CommandResponse GetAlertButtons(IDictionary parameters)
52 | {
53 | var alert = GetAppiumElement(parameters["element"]);
54 | if (alert is null)
55 | return CommandResponse.FailedEmptyResponse;
56 |
57 | var items = AppiumQuery.ByClass("android.widget.ListView")
58 | .FindElements(alert, _appiumApp)
59 | .FirstOrDefault()
60 | ?.ByClass("android.widget.TextView");
61 |
62 | var buttons = AppiumQuery.ByClass("android.widget.Button")
63 | .FindElements(alert, _appiumApp);
64 |
65 | var all = new List();
66 | if (items is not null)
67 | all.AddRange(items);
68 | all.AddRange(buttons);
69 |
70 | return new CommandResponse(all, CommandResponseResult.Success);
71 | }
72 |
73 | CommandResponse GetAlertText(IDictionary parameters)
74 | {
75 | var alert = GetAppiumElement(parameters["element"]);
76 | if (alert is null)
77 | return CommandResponse.FailedEmptyResponse;
78 |
79 | var text = AppiumQuery.ByClass("android.widget.TextView").FindElements(alert, _appiumApp);
80 | var strings = text.Select(t => t.GetText()).ToList();
81 |
82 | return new CommandResponse(strings, CommandResponseResult.Success);
83 | }
84 |
85 | static AppiumElement? GetAppiumElement(object element) =>
86 | element switch
87 | {
88 | AppiumElement appiumElement => appiumElement,
89 | AppiumDriverElement driverElement => driverElement.AppiumElement,
90 | _ => null
91 | };
92 | }
--------------------------------------------------------------------------------
/src/Plugin.Maui.UITestHelpers.Appium/Actions/AppiumAndroidSpecificActions.cs:
--------------------------------------------------------------------------------
1 | using OpenQA.Selenium.Appium.Android;
2 | using Plugin.Maui.UITestHelpers.Core;
3 |
4 | namespace Plugin.Maui.UITestHelpers.Appium
5 | {
6 | public class AppiumAndroidSpecificActions : ICommandExecutionGroup
7 | {
8 | const string ToggleAirplaneModeCommand = "toggleAirplaneMode";
9 | const string ToggleWifiCommand = "toggleWifi";
10 | const string GetPerformanceDataCommand = "getPerformanceData";
11 |
12 | readonly AppiumApp _appiumApp;
13 |
14 | readonly List _commands = new()
15 | {
16 | ToggleAirplaneModeCommand,
17 | ToggleWifiCommand,
18 | GetPerformanceDataCommand,
19 | };
20 |
21 | public AppiumAndroidSpecificActions(AppiumApp appiumApp)
22 | {
23 | _appiumApp = appiumApp;
24 | }
25 |
26 | public bool IsCommandSupported(string commandName)
27 | {
28 | return _commands.Contains(commandName, StringComparer.OrdinalIgnoreCase);
29 | }
30 |
31 | public CommandResponse Execute(string commandName, IDictionary parameters)
32 | {
33 | return commandName switch
34 | {
35 | ToggleAirplaneModeCommand => ToggleAirplaneMode(parameters),
36 | ToggleWifiCommand => ToggleWifi(parameters),
37 | GetPerformanceDataCommand => GetPerformanceData(parameters),
38 | _ => CommandResponse.FailedEmptyResponse,
39 | };
40 | }
41 |
42 | CommandResponse ToggleAirplaneMode(IDictionary parameters)
43 | {
44 | if (_appiumApp.Driver is AndroidDriver androidDriver)
45 | {
46 | // Toggle airplane mode on device.
47 | androidDriver.ToggleAirplaneMode();
48 |
49 | return CommandResponse.SuccessEmptyResponse;
50 | }
51 |
52 | return CommandResponse.FailedEmptyResponse;
53 | }
54 |
55 | CommandResponse ToggleWifi(IDictionary parameters)
56 | {
57 | if (_appiumApp.Driver is AndroidDriver androidDriver)
58 | {
59 | // Switch the state of the wifi service
60 | androidDriver.ToggleWifi();
61 |
62 | return CommandResponse.SuccessEmptyResponse;
63 | }
64 |
65 | return CommandResponse.FailedEmptyResponse;
66 | }
67 |
68 | CommandResponse GetPerformanceData(IDictionary parameters)
69 | {
70 | if (_appiumApp.Driver is AndroidDriver androidDriver)
71 | {
72 | string performanceDataType = (string)parameters["performanceDataType"];
73 |
74 | if (string.IsNullOrEmpty(performanceDataType))
75 | {
76 | performanceDataType = "memoryinfo";
77 | }
78 |
79 | // Returns the information of the system state which is supported to read as like cpu, memory, network traffic, and battery.
80 | IList