diff --git a/.github/workflows/ci-sample.yml b/.github/workflows/ci-sample.yml index 8d8e2aee..3aa8e6f8 100644 --- a/.github/workflows/ci-sample.yml +++ b/.github/workflows/ci-sample.yml @@ -8,6 +8,10 @@ on: pull_request: branches: [ "main" ] +env: + BUILD_CONFIGURATION: Release + CSPROJ_TO_BUILD: samples/Plugin.Maui.UITestHelpers.Sample/Plugin.Maui.UITestHelpers.Sample.csproj + jobs: build-sample-ci: @@ -15,5 +19,6 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Build - run: dotnet build samples\Plugin.Maui.UITestHelpers.Sample.sln -c Release + + - name: Build Sample App + run: dotnet build ${{ env.CSPROJ_TO_BUILD }} -c ${{ env.BUILD_CONFIGURATION }} \ No newline at end of file diff --git a/.github/workflows/ui-test-android.yml b/.github/workflows/ui-test-android.yml new file mode 100644 index 00000000..31474d84 --- /dev/null +++ b/.github/workflows/ui-test-android.yml @@ -0,0 +1,78 @@ +name: Run UI Tests Android + +on: + push: + branches: [ "main" ] + paths-ignore: + - "**.md" + pull_request: + branches: [ "main" ] + +env: + BUILD_CONFIGURATION: Release + CSPROJ_TO_BUILD: samples/Plugin.Maui.UITestHelpers.Sample/Plugin.Maui.UITestHelpers.Sample.csproj + APP_TO_TEST: samples/Plugin.Maui.UITestHelpers.Sample/bin/Release/net8.0-android/com.companyname.uitesthelperssample-Signed.apk + CSPROJ_TO_TEST: samples/UITests.Android/UITests.Android.csproj + APP_ID: com.companyname.uitesthelperssample + TARGET_FRAMEWORK: net8.0-android + TEST_EMULATOR_NAME: UITestEmu + ANDROID_EMULATOR_IMAGE: system-images;android-33;default;x86_64 + SCREENCAPTURE_FOLDER: samples/UITests.Android/bin/Debug/net8.0 + ARTIFACTS_PATH: ${{ github.workspace }}/output + +jobs: + ui-test-android: + + runs-on: macos-13 + + steps: + - uses: actions/checkout@v4 + + - name: Restore Workload + run: dotnet workload restore --project ${{ env.CSPROJ_TO_BUILD }} + + - name: Publish APK + run: dotnet publish ${{ env.CSPROJ_TO_BUILD }} -f ${{ env.TARGET_FRAMEWORK }} + + - name: Install xharness + run: | + dotnet tool install Microsoft.DotNet.XHarness.CLI \ + --global \ + --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json \ + --version "9.0.0-prerelease*" + + - name: Boot Android emulator + run: | + ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install '${{ env.ANDROID_EMULATOR_IMAGE }}' + + echo "no" | ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/avdmanager create avd --name ${{ env.TEST_EMULATOR_NAME }} --package '${{ env.ANDROID_EMULATOR_IMAGE }}' --force + + ${ANDROID_HOME}/tools/emulator -avd ${{ env.TEST_EMULATOR_NAME }} -gpu guest -memory 2048 -no-snapshot -no-audio -no-boot-anim -no-window -partition-size 4096 & + + # The device is now booting, or close to be booted + # We just wait until the sys.boot_completed property is set to 1. + while [ "`adb shell getprop sys.boot_completed | tr -d '\r' `" != "1" ] ; + do + echo "Still waiting for boot.." + sleep 10; + done + + - name: Install App + run: xharness android install --app=${{ env.APP_TO_TEST }} --package-name=${{ env.APP_ID }} --output-directory=${{ env.ARTIFACTS_PATH }}/xharness-logs + + - name: Install Appium + run: | + npm install -g appium + appium driver install uiautomator2 + + - name: Run UI Tests + run: dotnet test ${{ env.CSPROJ_TO_TEST }} --environment APPIUM_LOG_FILE=${{ env.ARTIFACTS_PATH }}/appium-logs/appium.log --environment APPID="${{ env.APP_ID }}" + + - name: Publish Artifacts + uses: actions/upload-artifact@v4 + if: always() + with: + name: logs-and-screenshots + path: | + ${{ env.ARTIFACTS_PATH }}/**/*.* + ${{ env.SCREENCAPTURE_FOLDER }}/*.png \ No newline at end of file diff --git a/.github/workflows/ui-test-ios.yml b/.github/workflows/ui-test-ios.yml new file mode 100644 index 00000000..1e1f6512 --- /dev/null +++ b/.github/workflows/ui-test-ios.yml @@ -0,0 +1,77 @@ +name: Run UI Tests iOS + +on: + push: + branches: [ "main" ] + paths-ignore: + - "**.md" + pull_request: + branches: [ "main" ] + +env: + # Release builds don't run on the Simulator + BUILD_CONFIGURATION: Debug + CSPROJ_TO_BUILD: samples/Plugin.Maui.UITestHelpers.Sample/Plugin.Maui.UITestHelpers.Sample.csproj + APP_TO_TEST: samples/Plugin.Maui.UITestHelpers.Sample/bin/Debug/net8.0-ios/iossimulator-arm64/Plugin.Maui.UITestHelpers.Sample.app + CSPROJ_TO_TEST: samples/UITests.iOS/UITests.iOS.csproj + APP_ID: com.companyname.uitesthelperssample + TARGET_FRAMEWORK: net8.0-ios + XCODE_VERSION: 15.2 + TEST_SIM_NAME: UITestSim + SCREENCAPTURE_FOLDER: samples/UITests.iOS/bin/Debug/net8.0 + ARTIFACTS_PATH: ${{ github.workspace }}/output + +jobs: + ui-test-ios: + + runs-on: macos-14 + + steps: + - uses: actions/checkout@v4 + + - name: Select Xcode version + run: sudo xcode-select -s '/Applications/Xcode_${{ env.XCODE_VERSION }}.app/Contents/Developer' + + - name: Restore Workload + run: dotnet workload restore --project ${{ env.CSPROJ_TO_BUILD }} + + - name: Build App + run: dotnet build ${{ env.CSPROJ_TO_BUILD }} -f ${{ env.TARGET_FRAMEWORK }} -c ${{ env.BUILD_CONFIGURATION }} + + - name: Install xharness + run: | + dotnet tool install Microsoft.DotNet.XHarness.CLI \ + --global \ + --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json \ + --version "9.0.0-prerelease*" + + - name: Install Appium + run: | + npm install -g appium + appium driver install xcuitest + + - name: Create iOS Simulator + # This creates a iPhone 15 Pro Simulator with iOS 16.4 + run: | + xharness apple simulators install ios-simulator_16.4 + simudid=$(xcrun simctl create ${{ env.TEST_SIM_NAME }} com.apple.CoreSimulator.SimDeviceType.iPhone-13 com.apple.CoreSimulator.SimRuntime.iOS-16-4) + echo "SIM_UDID=$(echo $simudid)" >> $GITHUB_ENV + echo "Created Simulator UDID: $simudid" + + - name: Install App + run: xharness apple install --app=${{ env.APP_TO_TEST }} --output-directory=${{ env.ARTIFACTS_PATH }}/xharness-logs --device="${{ env.SIM_UDID }}" --target=ios-simulator + + - name: Run UI Tests + # We're passing on the values we used to create the Simulator with to the test project to find the correct one + run: | + dotnet test ${{ env.CSPROJ_TO_TEST }} --environment SIMNAME="${{ env.TEST_SIM_NAME }}" --environment SIMID="${{ env.SIM_UDID }}" \ + --environment APPIUM_LOG_FILE=${{ env.ARTIFACTS_PATH }}/appium-logs/appium.log --environment APPID="${{ env.APP_ID }}" + + - name: Publish Artifacts + uses: actions/upload-artifact@v4 + if: always() + with: + name: logs-and-screenshots + path: | + ${{ env.ARTIFACTS_PATH }}/**/*.* + ${{ env.SCREENCAPTURE_FOLDER }}/*.png \ No newline at end of file diff --git a/.github/workflows/ui-test-macos.yml b/.github/workflows/ui-test-macos.yml new file mode 100644 index 00000000..32ea42b8 --- /dev/null +++ b/.github/workflows/ui-test-macos.yml @@ -0,0 +1,66 @@ +name: Run UI Tests macOS + +on: + push: + branches: [ "main" ] + paths-ignore: + - "**.md" + pull_request: + branches: [ "main" ] + +env: + BUILD_CONFIGURATION: Release + CSPROJ_TO_BUILD: samples/Plugin.Maui.UITestHelpers.Sample/Plugin.Maui.UITestHelpers.Sample.csproj + APP_TO_TEST: samples/Plugin.Maui.UITestHelpers.Sample/bin/Release/net8.0-maccatalyst/maccatalyst-arm64/Plugin.Maui.UITestHelpers.Sample.app + CSPROJ_TO_TEST: samples/UITests.macOS/UITests.macOS.csproj + APP_ID: com.companyname.uitesthelperssample + TARGET_FRAMEWORK: net8.0-maccatalyst + XCODE_VERSION: 15.2 + SCREENCAPTURE_FOLDER: samples/UITests.macOS/bin/Debug/net8.0 + ARTIFACTS_PATH: ${{ github.workspace }}/output + +jobs: + ui-test-macos: + + runs-on: macos-14 + + steps: + - uses: actions/checkout@v4 + + - name: Select Xcode version + run: sudo xcode-select -s '/Applications/Xcode_${{ env.XCODE_VERSION }}.app/Contents/Developer' + + - name: Restore Workload + run: dotnet workload restore --project ${{ env.CSPROJ_TO_BUILD }} + + - name: Build App + run: dotnet build ${{ env.CSPROJ_TO_BUILD }} -f ${{ env.TARGET_FRAMEWORK }} -c ${{ env.BUILD_CONFIGURATION }} + + - name: Install xharness + run: | + dotnet tool install Microsoft.DotNet.XHarness.CLI \ + --global \ + --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json \ + --version "9.0.0-prerelease*" + + - name: Install Appium + run: | + npm install -g appium + appium driver install mac2 + + - name: Install App + # Deploy the app by running it on this Mac + run: dotnet build ${{ env.CSPROJ_TO_BUILD }} -t:Run -f ${{ env.TARGET_FRAMEWORK }} -c ${{ env.BUILD_CONFIGURATION }} + + - name: Run UI Tests + run: | + dotnet test ${{ env.CSPROJ_TO_TEST }} --environment APPIUM_LOG_FILE=${{ env.ARTIFACTS_PATH }}/appium-logs/appium.log --environment APPID="${{ env.APP_ID }}" + + - name: Publish Artifacts + uses: actions/upload-artifact@v4 + if: always() + with: + name: logs-and-screenshots + path: | + ${{ env.ARTIFACTS_PATH }}/**/*.* + ${{ env.SCREENCAPTURE_FOLDER }}/*.png \ No newline at end of file diff --git a/.github/workflows/ui-test-windows.yml b/.github/workflows/ui-test-windows.yml new file mode 100644 index 00000000..56246b50 --- /dev/null +++ b/.github/workflows/ui-test-windows.yml @@ -0,0 +1,50 @@ +name: Run UI Tests Windows + +on: + push: + branches: [ "main" ] + paths-ignore: + - "**.md" + pull_request: + branches: [ "main" ] + +env: + BUILD_CONFIGURATION: Release + CSPROJ_TO_BUILD: samples/Plugin.Maui.UITestHelpers.Sample/Plugin.Maui.UITestHelpers.Sample.csproj + APP_TO_TEST: samples/Plugin.Maui.UITestHelpers.Sample/bin/Release/net8.0-windows10.0.19041.0/win10-x64/Plugin.Maui.UITestHelpers.Sample.exe + CSPROJ_TO_TEST: samples/UITests.Windows/UITests.Windows.csproj + TARGET_FRAMEWORK: net8.0-windows10.0.19041.0 + SCREENCAPTURE_FOLDER: samples/UITests.Windows/bin/Debug/net8.0 + ARTIFACTS_PATH: ${{ github.workspace }}/output + +jobs: + ui-test-windows: + + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + + - name: Build App + run: dotnet build ${{ env.CSPROJ_TO_BUILD }} -f ${{ env.TARGET_FRAMEWORK }} -c ${{ env.BUILD_CONFIGURATION }} + + - name: Install Appium + run: | + npm install -g appium + appium driver install --source=npm appium-windows-driver + + - name: Run UI Tests + run: | + # Set environment variable separately because of https://github.com/dotnet/sdk/issues/40848 + $absolutePath = ("${{ env.APP_TO_TEST }}" | Resolve-Path).Path + $env:APPID = $absolutePath + dotnet test ${{ env.CSPROJ_TO_TEST }} --environment APPIUM_LOG_FILE=${{ env.ARTIFACTS_PATH }}/appium-logs/appium.log + + - name: Publish Artifacts + uses: actions/upload-artifact@v4 + if: always() + with: + name: logs-and-screenshots + path: | + ${{ env.ARTIFACTS_PATH }}/**/*.* + ${{ env.SCREENCAPTURE_FOLDER }}/*.png \ No newline at end of file diff --git a/samples/Plugin.Maui.UITestHelpers.Sample.sln b/samples/Plugin.Maui.UITestHelpers.Sample.sln index e0605254..97db3993 100644 --- a/samples/Plugin.Maui.UITestHelpers.Sample.sln +++ b/samples/Plugin.Maui.UITestHelpers.Sample.sln @@ -1,12 +1,19 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 + +Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31611.283 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Plugin.Maui.UITestHelpers.Sample", "Plugin.Maui.UITestHelpers.Sample\Plugin.Maui.UITestHelpers.Sample.csproj", "{490BB138-9606-4FFF-8AAD-841C5B1ED059}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UITests.Android", "UITests.Android\UITests.Android.csproj", "{6557E077-F81A-4D64-B3C4-A07BB1BD31D4}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UITests.Android", "UITests.Android\UITests.Android.csproj", "{6557E077-F81A-4D64-B3C4-A07BB1BD31D4}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UITests.Shared", "UITests.Shared\UITests.Shared.csproj", "{DFD0E4D0-3519-4B55-8B31-CC7AF8106AAE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UITests.Shared", "UITests.Shared\UITests.Shared.csproj", "{DFD0E4D0-3519-4B55-8B31-CC7AF8106AAE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UITests.iOS", "UITests.iOS\UITests.iOS.csproj", "{2B36F0AB-6CF2-4EE8-8561-3A436304B744}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UITests.macOS", "UITests.macOS\UITests.macOS.csproj", "{74557CDA-CB45-4719-9A7D-DE35B10B7345}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UITests.Windows", "UITests.Windows\UITests.Windows.csproj", "{1A0A722B-2D19-42C6-A306-1417A283B244}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -28,6 +35,18 @@ Global {DFD0E4D0-3519-4B55-8B31-CC7AF8106AAE}.Debug|Any CPU.Build.0 = Debug|Any CPU {DFD0E4D0-3519-4B55-8B31-CC7AF8106AAE}.Release|Any CPU.ActiveCfg = Release|Any CPU {DFD0E4D0-3519-4B55-8B31-CC7AF8106AAE}.Release|Any CPU.Build.0 = Release|Any CPU + {2B36F0AB-6CF2-4EE8-8561-3A436304B744}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2B36F0AB-6CF2-4EE8-8561-3A436304B744}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2B36F0AB-6CF2-4EE8-8561-3A436304B744}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2B36F0AB-6CF2-4EE8-8561-3A436304B744}.Release|Any CPU.Build.0 = Release|Any CPU + {74557CDA-CB45-4719-9A7D-DE35B10B7345}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {74557CDA-CB45-4719-9A7D-DE35B10B7345}.Debug|Any CPU.Build.0 = Debug|Any CPU + {74557CDA-CB45-4719-9A7D-DE35B10B7345}.Release|Any CPU.ActiveCfg = Release|Any CPU + {74557CDA-CB45-4719-9A7D-DE35B10B7345}.Release|Any CPU.Build.0 = Release|Any CPU + {1A0A722B-2D19-42C6-A306-1417A283B244}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1A0A722B-2D19-42C6-A306-1417A283B244}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1A0A722B-2D19-42C6-A306-1417A283B244}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1A0A722B-2D19-42C6-A306-1417A283B244}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/samples/Plugin.Maui.UITestHelpers.Sample/Plugin.Maui.UITestHelpers.Sample.csproj b/samples/Plugin.Maui.UITestHelpers.Sample/Plugin.Maui.UITestHelpers.Sample.csproj index 68c99fa5..e72c6597 100644 --- a/samples/Plugin.Maui.UITestHelpers.Sample/Plugin.Maui.UITestHelpers.Sample.csproj +++ b/samples/Plugin.Maui.UITestHelpers.Sample/Plugin.Maui.UITestHelpers.Sample.csproj @@ -16,7 +16,6 @@ com.companyname.uitesthelperssample - A20E30BB-3BF7-4ACB-89F2-596834136909 1.0 @@ -30,6 +29,11 @@ 6.5 + + None + false + + diff --git a/samples/UITests.Android/UITests.Android.csproj b/samples/UITests.Android/UITests.Android.csproj index cd7470b3..1e20c99a 100644 --- a/samples/UITests.Android/UITests.Android.csproj +++ b/samples/UITests.Android/UITests.Android.csproj @@ -1,31 +1,31 @@ - - net8.0 - enable - enable - true - UITests - + + net8.0 + enable + enable + true + UITests + - - $(DefineConstants);ANDROID - + + $(DefineConstants);ANDROID + - - - - - - + + + + + + - - - + + + - - - - + + + + \ No newline at end of file diff --git a/samples/UITests.Shared/BaseTest.cs b/samples/UITests.Shared/BaseTest.cs index 1838ce39..70615eb5 100644 --- a/samples/UITests.Shared/BaseTest.cs +++ b/samples/UITests.Shared/BaseTest.cs @@ -1,5 +1,6 @@ using NUnit.Framework; using Plugin.Maui.UITestHelpers.Core; +using System.Diagnostics; using UITest.Appium.NUnit; namespace UITests.Shared; @@ -8,6 +9,10 @@ namespace UITests.Shared; [TestFixture(TestDevice.Android)] #elif IOS [TestFixture(TestDevice.iOS)] +#elif MACOS +[TestFixture(TestDevice.Mac)] +#elif WINDOWS +[TestFixture(TestDevice.Windows)] #endif public abstract class BaseTest : UITestBase { @@ -19,13 +24,40 @@ public override IConfig GetTestConfig() { var config = new Config(); + var appIdentifierKey = "AppId"; + // Note: an app with this ID has to be deployed to the emulator/device you want to run it on - config.SetProperty("AppId", "com.companyname.uitesthelperssample"); + var appIdentifier = "com.companyname.uitesthelperssample"; + + if (_testDevice == TestDevice.Windows) + { + appIdentifierKey = "AppPath"; + + // Note: a release build has to be done and the path to this .exe file should exist. Tweak this path if necessary + var absolutePath = Path.GetFullPath("..\\..\\..\\..\\Plugin.Maui.UITestHelpers.Sample\\bin\\Release\\net8.0-windows10.0.19041.0\\win10-x64\\Plugin.Maui.UITestHelpers.Sample.exe"); + appIdentifier = absolutePath; + } + + // If the app ID is provided through an environment variable, like through CI, use that instead + if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("APPID"))) + { + appIdentifier = Environment.GetEnvironmentVariable("APPID"); + } + + config.SetProperty(appIdentifierKey, appIdentifier); if (_testDevice == TestDevice.iOS) { - config. SetProperty("DeviceName", "iPhone 15 Pro"); - config.SetProperty("PlatformVersion", "17.2"); + // Note: this is passed down from the GitHub Action. If nothing is set, fall back to a default value below + if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("SIMID"))) + { + config.SetProperty("Udid", Environment.GetEnvironmentVariable("SIMID")); + } + else + { + config.SetProperty("DeviceName", "iPhone 15 Pro"); + config.SetProperty("PlatformVersion", "17.2"); + } } return config; diff --git a/samples/UITests.Shared/MainPageTests.cs b/samples/UITests.Shared/MainPageTests.cs index 62009467..cb9bbe47 100644 --- a/samples/UITests.Shared/MainPageTests.cs +++ b/samples/UITests.Shared/MainPageTests.cs @@ -19,9 +19,12 @@ public void AppLaunches() [Test] public void ClickCounterTest() { + const string elementId = "CounterBtn"; + // Arrange // Find elements with the value of the AutomationId property - var element = App.FindElement("CounterBtn"); + var element = App.FindElement(elementId); + App.WaitForElement(elementId); // Act element.Click(); diff --git a/samples/UITests.Shared/UITests.Shared.csproj b/samples/UITests.Shared/UITests.Shared.csproj index 8799b281..27fc03c3 100644 --- a/samples/UITests.Shared/UITests.Shared.csproj +++ b/samples/UITests.Shared/UITests.Shared.csproj @@ -1,14 +1,14 @@ - - - net8.0 - False - False - UITests - - - - + + net8.0 + False + False + UITests + + + + + \ No newline at end of file diff --git a/samples/UITests.Windows/UITests.Windows.csproj b/samples/UITests.Windows/UITests.Windows.csproj new file mode 100644 index 00000000..1aaf7966 --- /dev/null +++ b/samples/UITests.Windows/UITests.Windows.csproj @@ -0,0 +1,31 @@ + + + + net8.0 + enable + enable + true + UITests + + + + $(DefineConstants);WINDOWS + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/UITests.iOS/UITests.iOS.csproj b/samples/UITests.iOS/UITests.iOS.csproj index ca232898..12a43d49 100644 --- a/samples/UITests.iOS/UITests.iOS.csproj +++ b/samples/UITests.iOS/UITests.iOS.csproj @@ -1,31 +1,31 @@ - - net8.0 - enable - enable - true - UITests - + + net8.0 + enable + enable + true + UITests + - - $(DefineConstants);IOS - + + $(DefineConstants);IOS + - - - - - - + + + + + + - - - + + + - - - - + + + + \ No newline at end of file diff --git a/samples/UITests.macOS/UITests.macOS.csproj b/samples/UITests.macOS/UITests.macOS.csproj new file mode 100644 index 00000000..feae6e03 --- /dev/null +++ b/samples/UITests.macOS/UITests.macOS.csproj @@ -0,0 +1,31 @@ + + + + net8.0 + enable + enable + true + UITests + + + + $(DefineConstants);MACOS + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Plugin.Maui.UITestHelpers.Appium/AppiumServerContext.cs b/src/Plugin.Maui.UITestHelpers.Appium/AppiumServerContext.cs index ef29b450..765729e0 100644 --- a/src/Plugin.Maui.UITestHelpers.Appium/AppiumServerContext.cs +++ b/src/Plugin.Maui.UITestHelpers.Appium/AppiumServerContext.cs @@ -26,6 +26,13 @@ public IUIClientContext CreateUIClientContext(IConfig config) } int retries = 0; + int maxRetries = 10; + + if (Environment.GetEnvironmentVariable("CI")?.ToLower().Equals("true") ?? false) + { + // Things can take long with CI + maxRetries = 100; + } var testDevice = config.GetProperty("TestDevice"); var driverUri = new Uri($"http://localhost:{Port}/wd/hub"); @@ -51,7 +58,7 @@ public IUIClientContext CreateUIClientContext(IConfig config) catch (WebDriverException) { // Default command timeout is 60 seconds when executing the NewSessionCommand - if (retries++ < 10) + if (retries++ < maxRetries) { Debug.WriteLine($">>>>> Retrying to create the driver, attempt #{retries}"); } diff --git a/src/Plugin.Maui.UITestHelpers.Appium/Plugin.Maui.UITestHelpers.Appium.csproj b/src/Plugin.Maui.UITestHelpers.Appium/Plugin.Maui.UITestHelpers.Appium.csproj index a8a144c0..c8084df6 100644 --- a/src/Plugin.Maui.UITestHelpers.Appium/Plugin.Maui.UITestHelpers.Appium.csproj +++ b/src/Plugin.Maui.UITestHelpers.Appium/Plugin.Maui.UITestHelpers.Appium.csproj @@ -27,8 +27,8 @@ - - + +