Skip to content

Commit

Permalink
Amend the Appium simple example to Sauce new demo apps
Browse files Browse the repository at this point in the history
  • Loading branch information
eyaly committed Feb 12, 2024
1 parent 66a0050 commit 350f637
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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<String> 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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@ 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.

> The advice is to download the files to an `apps` folder in the root of this folder.
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!**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 350f637

Please sign in to comment.