diff --git a/appium/appium-app/appium-app-examples/src/test/java/com/examples/simple_example/AndroidNativeAppTest.java b/appium/appium-app/appium-app-examples/src/test/java/com/examples/simple_example/AndroidNativeAppTest.java index 267f5793..3aa54abd 100644 --- a/appium/appium-app/appium-app-examples/src/test/java/com/examples/simple_example/AndroidNativeAppTest.java +++ b/appium/appium-app/appium-app-examples/src/test/java/com/examples/simple_example/AndroidNativeAppTest.java @@ -1,6 +1,7 @@ package com.examples.simple_example; import com.helpers.SauceAppiumTestWatcher; +import io.appium.java_client.AppiumBy; import io.appium.java_client.android.AndroidDriver; import org.junit.Before; import org.junit.Rule; @@ -25,9 +26,9 @@ */ public class AndroidNativeAppTest { - By productsScreenLocator = By.xpath("//*[@content-desc=\"products screen\"]"); - By sortButtonLocator = By.xpath("//*[@content-desc=\"sort button\"]"); - By sortModalLocator = By.xpath("//*[@content-desc=\"active option\"]"); + By productsScreenLocator = By.id("com.saucelabs.mydemoapp.android:id/productTV"); + By sortButtonLocator = AppiumBy.accessibilityId("Shows current sorting order and displays available sorting options"); + By sortModalLocator = By.id("com.saucelabs.mydemoapp.android:id/sortTV"); @Rule @@ -75,18 +76,19 @@ public void setup() throws MalformedURLException { capabilities.setCapability("appium:deviceName", "Android GoogleAPI Emulator"); } capabilities.setCapability("appium:platformVersion", "12"); - String appName = "Android.MyDemoAppRN.apk"; + String appName = "SauceLabs-Demo-App.apk"; capabilities.setCapability("appium:app", "storage:filename=" +appName); - capabilities.setCapability("appium:appWaitActivity","com.saucelabs.mydemoapp.rn.MainActivity"); // Sauce capabilities sauceOptions.setCapability("name", name.getMethodName()); + sauceOptions.setCapability("appiumVersion", "latest"); sauceOptions.setCapability("build", "myApp-job-1"); List tags = Arrays.asList("sauceDemo", "Android", "Demo"); sauceOptions.setCapability("tags", tags); sauceOptions.setCapability("username", System.getenv("SAUCE_USERNAME")); sauceOptions.setCapability("accessKey", System.getenv("SAUCE_ACCESS_KEY")); + capabilities.setCapability("sauce:options", sauceOptions); try { diff --git a/appium/appium-app/appium-app-examples/src/test/java/com/examples/simple_example/IOSNativeAppTest.java b/appium/appium-app/appium-app-examples/src/test/java/com/examples/simple_example/IOSNativeAppTest.java index 4346585f..f681ce46 100644 --- a/appium/appium-app/appium-app-examples/src/test/java/com/examples/simple_example/IOSNativeAppTest.java +++ b/appium/appium-app/appium-app-examples/src/test/java/com/examples/simple_example/IOSNativeAppTest.java @@ -1,6 +1,7 @@ package com.examples.simple_example; import com.helpers.SauceAppiumTestWatcher; +import io.appium.java_client.AppiumBy; import io.appium.java_client.ios.IOSDriver; import org.junit.Before; import org.junit.Rule; @@ -22,9 +23,9 @@ public class IOSNativeAppTest { - By productsScreenLocator = By.id("products screen"); - By sortButtonLocator = By.id("sort button"); - By sortModalLocator = By.id("active option"); + By productsScreenLocator = AppiumBy.accessibilityId("Products"); + By sortButtonLocator = AppiumBy.iOSClassChain("**/XCUIElementTypeButton[`name == \"Button\"`]"); + By sortModalLocator = AppiumBy.accessibilityId("Sort by:"); @Rule public TestName name = new TestName(); @@ -64,14 +65,14 @@ public void setUp() throws MalformedURLException { if (rdc.equals("true")) { //Allocate any avilable iPhone device with version 14 capabilities.setCapability("appium:deviceName", "iPhone.*"); - appName = "iOS.MyDemoAppRN.ipa"; + appName = "SauceLabs-Demo-App.ipa"; sauceOptions.setCapability("resigningEnabled", true); sauceOptions.setCapability("sauceLabsNetworkCaptureEnabled", true); } else { capabilities.setCapability("appium:deviceName", "iPhone 11 Simulator"); - appName = "iOS.MyDemoAppRN.zip"; + appName = "SauceLabs-Demo-App.Simulator.zip"; } capabilities.setCapability("appium:platformVersion", "14"); capabilities.setCapability("app", "storage:filename=" + appName); @@ -94,7 +95,7 @@ public void setUp() throws MalformedURLException { } @Test - public void verifyInProductsPage() throws MalformedURLException { + public void verifyPromptSortModal() throws MalformedURLException { WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10)); wait.until(ExpectedConditions.visibilityOfElementLocated(productsScreenLocator)); diff --git a/appium/appium-app/appium-app-examples/src/test/java/com/examples/simple_example/README.md b/appium/appium-app/appium-app-examples/src/test/java/com/examples/simple_example/README.md index dde62025..2357e763 100644 --- a/appium/appium-app/appium-app-examples/src/test/java/com/examples/simple_example/README.md +++ b/appium/appium-app/appium-app-examples/src/test/java/com/examples/simple_example/README.md @@ -16,7 +16,8 @@ The examples in this repository use environment variables, make sure you've adde export SAUCE_ACCESS_KEY=******* ### Demo app(s) -The demo app that has been used for all these tests can be found [here](https://github.com/saucelabs/my-demo-app-rn/releases). +The Android demo app that has been used for all these tests can be found [here](https://github.com/saucelabs/my-demo-app-android/releases). +The iOS demo app that has been used for all these tests can be found [here](https://github.com/saucelabs/my-demo-app-ios/releases). Be aware of the fact that and iOS simulator uses a different build then a iOS real device. So please check the file you download. @@ -24,9 +25,7 @@ download. Make sure that when you downloaded the files from the releases page, that you rename the apps to the following: -- `Android-MyDemoAppRN.{#.#.#}.build-{####}.apk` => `Android.MyDemoAppRN.apk` -- `iOS-Real-Device-MyRNDemoApp.{#.#.#}-{####}.ipa` => `iOS.MyDemoAppRN.ipa` -- `iOS-Simulator-MyRNDemoApp.{#.#.#}-{####}.zip` => `iOS.MyDemoAppRN.zip` +- `mda-{#.#.#}.apk` => `SauceLabs-Demo-App.apk` **If you don't do that then the scripts can't find the apps!** diff --git a/appium/appium-web/appium-web-examples/src/test/java/com/examples/simple_example/AndroidWebAppTest.java b/appium/appium-web/appium-web-examples/src/test/java/com/examples/simple_example/AndroidWebAppTest.java index c6483c09..e9cbe0ea 100644 --- a/appium/appium-web/appium-web-examples/src/test/java/com/examples/simple_example/AndroidWebAppTest.java +++ b/appium/appium-web/appium-web-examples/src/test/java/com/examples/simple_example/AndroidWebAppTest.java @@ -67,11 +67,11 @@ public void setup() throws MalformedURLException { capabilities.setCapability("appium:automationName", "UiAutomator2"); if (rdc.equals("true")) { capabilities.setCapability("appium:deviceName", "samsung.*"); - sauceOptions.setCapability("appiumVersion", "2.0.0"); + sauceOptions.setCapability("appiumVersion", "latest"); } else { capabilities.setCapability("appium:deviceName", "Android GoogleAPI Emulator"); - sauceOptions.setCapability("appiumVersion", "2.0.0-beta66"); + sauceOptions.setCapability("appiumVersion", "latest"); } capabilities.setCapability("appium:platformVersion", "13");