diff --git a/.github/workflows/Semgrep.yml b/.github/workflows/Semgrep.yml
index 0347afd..95c5710 100644
--- a/.github/workflows/Semgrep.yml
+++ b/.github/workflows/Semgrep.yml
@@ -27,8 +27,7 @@ jobs:
container:
# A Docker image with Semgrep installed. Do not change this.
- image: returntocorp/semgrep
-
+ image: returntocorp/semgrep:1.166.0
# Skip any PR created by dependabot to avoid permission issues:
if: (github.actor != 'dependabot[bot]')
diff --git a/.github/workflows/sanity-workflow.yml b/.github/workflows/sanity-workflow.yml
index f4a83ef..a643564 100644
--- a/.github/workflows/sanity-workflow.yml
+++ b/.github/workflows/sanity-workflow.yml
@@ -72,6 +72,22 @@ jobs:
cd junit-4/ios
mvn compile
mvn test -P sample-local-test -D"browserstack.app"="./LocalSample.ipa"
+ - name: Run gradle test for junit4 android
+ run: |
+ cd junit-4/android
+ gradle clean sampleTest
+ - name: Run gradle sample-local-test for junit4 android
+ run: |
+ cd junit-4/android
+ gradle clean sampleLocalTest -D"browserstack.app"="./LocalSample.apk"
+ - name: Run gradle test for junit4 ios
+ run: |
+ cd junit-4/ios
+ gradle clean sampleTest
+ - name: Run gradle sample-local-test for junit4 ios
+ run: |
+ cd junit-4/ios
+ gradle clean sampleLocalTest -D"browserstack.app"="./LocalSample.ipa"
- name: Run mvn test for junit5 android
run: |
cd junit-5/android
@@ -92,6 +108,22 @@ jobs:
cd junit-5/ios
mvn compile
mvn test -P sample-local-test -D"browserstack.app"="./LocalSample.ipa"
+ - name: Run gradle test for junit5 android
+ run: |
+ cd junit-5/android
+ gradle clean sampleTest
+ - name: Run gradle sample-local-test for junit5 android
+ run: |
+ cd junit-5/android
+ gradle clean sampleLocalTest -D"browserstack.app"="./LocalSample.apk"
+ - name: Run gradle test for junit5 ios
+ run: |
+ cd junit-5/ios
+ gradle clean sampleTest
+ - name: Run gradle sample-local-test for junit5 ios
+ run: |
+ cd junit-5/ios
+ gradle clean sampleLocalTest -D"browserstack.app"="./LocalSample.ipa"
- if: always()
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
id: status-check-completed
diff --git a/.gitignore b/.gitignore
index 871cd6a..a6c60e4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,4 +2,11 @@
target/
local.log
.idea
+*/*/logs
*.iml
+bstack_*
+gradlew*
+gradle
+.gradle
+build
+reports
diff --git a/README.md b/README.md
index a0bd488..8728e37 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,13 @@ This repository demonstrates how to run Appium tests in [JUnit4](http://junit.or

+## Based on
+
+These code samples are currently based on:
+
+- **Appium-Java-Client:** `8.1.1`
+- **Protocol:** `W3C`
+
## Setup
### Requirements
@@ -14,43 +21,49 @@ This repository demonstrates how to run Appium tests in [JUnit4](http://junit.or
- For Windows, download latest java version from [here](https://java.com/en/download/) and run the installer executable
- For Mac and Linux, run `java -version` to see what java version is pre-installed. If you want a different version download from [here](https://java.com/en/download/)
-2. Maven
+2. Maven (Only required if using Maven as the build tool)
+
- If Maven is not downloaded, download it from [here](https://maven.apache.org/download.cgi)
- For installation, follow the instructions [here](https://maven.apache.org/install.html)
+3. Gradle (Only required if using Gradle as the build tool)
+
+ - If Gradle is not downloaded, download it from [here](https://gradle.org/releases/)
+ - For installation, follow the instructions [here](https://gradle.org/install/)
+
### Install the dependencies
-To install the dependencies for Android tests, run :
+To install the dependencies for JUnit4 tests, run :
-- For Junit4
+- For Android
```sh
- cd android/junit4-examples
+ cd junit-4/android
mvn clean
```
-- For Junit5
+- For iOS
```sh
- cd android/junit5-examples
+ cd junit-4/ios
mvn clean
```
Or,
-To install the dependencies for iOS tests, run :
+To install the dependencies for JUnit5 tests, run :
-- For Junit4
+- For Android
```sh
- cd ios/junit4-examples
+ cd junit-5/android
mvn clean
```
-- For Junit5
+- For iOS
```sh
- cd ios/junit5-examples
+ cd junit-5/ios
mvn clean
```
@@ -61,32 +74,58 @@ Getting Started with Appium tests in Junit4 and Junit5 on BrowserStack couldn't
### **Run first test :**
- Junit4
- - Switch to `run_first_test` directory under [Android Junit4 examples](android/junit4-examples) or [iOS Junit4 examples](ios/junit4-examples)
- - Follow the steps outlined in the documentation - [Get Started with your first test on App Automate](https://www.browserstack.com/docs/app-automate/appium/getting-started/java/junit)
-
-- Junit5
- - Switch to `run_first_test` directory under [Android Junit5 examples](android/junit5-examples) or [iOS Junit5 examples](ios/junit5-examples)
- - Follow the steps outlined in the documentation - [Get Started with your first test on App Automate](https://www.browserstack.com/docs/app-automate/appium/getting-started/java/junit)
-
-### **Speed up test execution with parallel testing :**
+ - Update `browserstack.yml` file at root level of [Android Junit4 examples](junit-4/android) or [iOS Junit4 examples](junit-4/ios) with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
+ - **For Maven:** Run the following command to execute tests in the Maven environment:
+ ```sh
+ mvn test -P sample-test
+ ```
+ - **For Gradle:** Run the following command to execute tests in the Gradle environment:
+ ```sh
+ gradle clean sampleTest
+ ```
-- Junit4
- - Switch to `run_parallel_test` directory under [Android Junit4 examples](android/junit4-examples/) or [iOS Junit4 examples](ios/junit4-examples/)
- - Follow the steps outlined in the documentation - [Get Started with parallel testing on App Automate](https://www.browserstack.com/docs/app-automate/appium/getting-started/java/junit/parallelize-tests)
-
- Junit5
- - Switch to `run_parallel_test` directory under [Android Junit5 examples](android/junit5-examples/) or [iOS Junit5 examples](ios/junit5-examples/)
- - Follow the steps outlined in the documentation - [Get Started with parallel testing on App Automate](https://www.browserstack.com/docs/app-automate/appium/getting-started/java/junit/parallelize-tests)
+ - Update `browserstack.yml` file at root level of [Android Junit5 examples](junit-5/android) or [iOS Junit5 examples](junit-5/ios) with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
+ - **For Maven:** Run the following command to execute tests in the Maven environment:
+ ```sh
+ mvn test -P sample-test
+ ```
+ - **For Gradle:** Run the following command to execute tests in the Gradle environment:
+ ```sh
+ gradle clean sampleTest
+ ```
### **Use Local testing for apps that access resources hosted in development or testing environments :**
- Junit4
- - Switch to `run_local_test` directory under [Android Junit4 examples](android/junit4-examples/) or [iOS Junit4 examples](ios/junit4-examples/)
- - Follow the steps outlined in the documentation - [Get Started with Local testing on App Automate](https://www.browserstack.com/docs/app-automate/appium/getting-started/java/junit/local-testing)
+ - Update `browserstack.yml` file at root level of [Android Junit4 examples](junit-4/android) or [iOS Junit4 examples](junit-4/ios) with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
+ - Simply configure the browserstackLocal parameter in the browserstack.yml file accordingly in [Android Junit4 examples](junit-4/android) or [iOS Junit4 examples](junit-4/ios).
+ ```
+ browserstackLocal: true
+ ```
+ - **For Maven:** Run the following command to execute tests in the Maven environment:
+ ```sh
+ mvn test -P sample-local-test
+ ```
+ - **For Gradle:** Run the following command to execute tests in the Gradle environment:
+ ```sh
+ gradle clean sampleLocalTest
+ ```
- Junit5
- - Switch to `run_local_test` directory under [Android Junit5 examples](android/junit5-examples/) or [iOS Junit5 examples](ios/junit5-examples/)
- - Follow the steps outlined in the documentation - [Get Started with Local testing on App Automate](https://www.browserstack.com/docs/app-automate/appium/getting-started/java/junit/local-testing)
+ - Update `browserstack.yml` file at root level of Android Junit5 examples or iOS Junit5 examples with your [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings)
+ - Simply configure the browserstackLocal parameter in the browserstack.yml file accordingly in [Android Junit5 examples](junit-5/android) or [iOS Junit5 examples](junit-5/ios).
+ ```
+ browserstackLocal: true
+ ```
+ - **For Maven:** Run the following command to execute tests in the Maven environment:
+ ```sh
+ mvn test -P sample-local-test
+ ```
+ - **For Gradle:** Run the following command to execute tests in the Gradle environment:
+ ```sh
+ gradle clean sampleLocalTest
+ ```
**Note**: If you are facing any issues, refer [Getting Help section](#Getting-Help)
diff --git a/android/junit4-examples/pom.xml b/android/junit4-examples/pom.xml
deleted file mode 100644
index 3e0ff5f..0000000
--- a/android/junit4-examples/pom.xml
+++ /dev/null
@@ -1,126 +0,0 @@
-
- 4.0.0
-
- com.browserstack
- junit4-browserstack
- 1.0-SNAPSHOT
- jar
-
- junit-browserstack
- https://www.github.com/browserstack/junit-appium-app-browserstack
-
-
- UTF-8
- 2.19.1
-
-
- default
-
-
-
-
- junit
- junit
- 4.12
-
-
- commons-io
- commons-io
- 1.3.2
-
-
- org.seleniumhq.selenium
- selenium-java
- 3.141.59
-
-
- io.appium
- java-client
- 7.0.0
-
-
- com.browserstack
- browserstack-local-java
- 1.0.3
-
-
- com.googlecode.json-simple
- json-simple
- 1.1.1
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 2.22.2
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.8.1
-
- 1.8
- 1.8
-
-
-
-
-
-
-
- first
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- com/browserstack/run_first_test/FirstTest.java
-
-
-
-
-
-
-
-
- local
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- com/browserstack/run_local_test/LocalTest.java
-
-
-
-
-
-
-
-
- parallel
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- com/browserstack/run_parallel_test/ParallelTest.java
-
-
-
-
-
-
-
-
-
diff --git a/android/junit4-examples/src/test/java/com/browserstack/run_first_test/BrowserStackJUnitTest.java b/android/junit4-examples/src/test/java/com/browserstack/run_first_test/BrowserStackJUnitTest.java
deleted file mode 100644
index 9d9dd78..0000000
--- a/android/junit4-examples/src/test/java/com/browserstack/run_first_test/BrowserStackJUnitTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package com.browserstack.run_first_test;
-
-import java.net.URL;
-import java.util.Map;
-import java.util.List;
-import java.util.Iterator;
-import java.util.ArrayList;
-import java.io.FileReader;
-
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-
-import io.appium.java_client.android.AndroidDriver;
-import io.appium.java_client.android.AndroidElement;
-
-import org.junit.runners.Parameterized;
-import org.openqa.selenium.remote.DesiredCapabilities;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(Parameterized.class)
-public class BrowserStackJUnitTest {
- public AndroidDriver driver;
-
- private static JSONObject config;
-
- @Parameter(value = 0)
- public int taskID;
-
- @Parameters
- public static Iterable extends Object> data() throws Exception {
- List taskIDs = new ArrayList();
-
- JSONParser parser = new JSONParser();
- config = (JSONObject) parser.parse(new FileReader("src/test/resources/com/browserstack/run_first_test/first.conf.json"));
- int envs = ((JSONArray) config.get("environments")).size();
-
- for (int i = 0; i < envs; i++) {
- taskIDs.add(i);
- }
-
- return taskIDs;
- }
-
- @Before
- public void setUp() throws Exception {
- JSONArray envs = (JSONArray) config.get("environments");
-
- DesiredCapabilities capabilities = new DesiredCapabilities();
-
- Map envCapabilities = (Map) envs.get(taskID);
- Iterator it = envCapabilities.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pair = (Map.Entry) it.next();
- capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
- }
-
- Map commonCapabilities = (Map) config.get("capabilities");
- it = commonCapabilities.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pair = (Map.Entry) it.next();
- if (capabilities.getCapability(pair.getKey().toString()) == null) {
- capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
- }
- }
-
- String username = System.getenv("BROWSERSTACK_USERNAME");
- if (username == null) {
- username = (String) config.get("username");
- }
-
- String accessKey = System.getenv("BROWSERSTACK_ACCESS_KEY");
- if (accessKey == null) {
- accessKey = (String) config.get("access_key");
- }
-
- String app = System.getenv("BROWSERSTACK_APP_ID");
- if (app != null && !app.isEmpty()) {
- capabilities.setCapability("app", app);
- }
-
- driver = new AndroidDriver(new URL("http://" + username + ":" + accessKey + "@" + config.get("server") + "/wd/hub"), capabilities);
- }
-
- @After
- public void tearDown() throws Exception {
- // Invoke driver.quit() to indicate that the test is completed.
- // Otherwise, it will appear as timed out on BrowserStack.
- driver.quit();
- }
-}
diff --git a/android/junit4-examples/src/test/java/com/browserstack/run_first_test/FirstTest.java b/android/junit4-examples/src/test/java/com/browserstack/run_first_test/FirstTest.java
deleted file mode 100644
index c6afc6a..0000000
--- a/android/junit4-examples/src/test/java/com/browserstack/run_first_test/FirstTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.browserstack.run_first_test;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-import java.util.List;
-
-import io.appium.java_client.MobileBy;
-import io.appium.java_client.android.AndroidElement;
-
-import org.openqa.selenium.support.ui.WebDriverWait;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-
-public class FirstTest extends BrowserStackJUnitTest {
-
- @Test
- public void test() throws Exception {
- AndroidElement searchElement = (AndroidElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Search Wikipedia")));
- searchElement.click();
- AndroidElement insertTextElement = (AndroidElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.id("org.wikipedia.alpha:id/search_src_text")));
- insertTextElement.sendKeys("BrowserStack");
- Thread.sleep(5000);
-
- List allProductsName = driver.findElementsByClassName("android.widget.TextView");
- assertTrue(allProductsName.size() > 0);
- }
-}
diff --git a/android/junit4-examples/src/test/java/com/browserstack/run_local_test/BrowserStackJUnitTest.java b/android/junit4-examples/src/test/java/com/browserstack/run_local_test/BrowserStackJUnitTest.java
deleted file mode 100644
index ce59c3f..0000000
--- a/android/junit4-examples/src/test/java/com/browserstack/run_local_test/BrowserStackJUnitTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package com.browserstack.run_local_test;
-
-import com.browserstack.local.Local;
-
-import java.net.URL;
-import java.util.Map;
-import java.util.List;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.ArrayList;
-import java.io.FileReader;
-
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-
-import io.appium.java_client.android.AndroidDriver;
-import io.appium.java_client.android.AndroidElement;
-
-import org.junit.runners.Parameterized;
-import org.openqa.selenium.remote.DesiredCapabilities;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(Parameterized.class)
-public class BrowserStackJUnitTest {
- public AndroidDriver driver;
- private Local local;
-
- private static JSONObject config;
-
- @Parameter(value = 0)
- public int taskID;
-
- @Parameters
- public static Iterable extends Object> data() throws Exception {
- List taskIDs = new ArrayList();
-
- JSONParser parser = new JSONParser();
- config = (JSONObject) parser.parse(new FileReader("src/test/resources/com/browserstack/run_local_test/local.conf.json"));
- int envs = ((JSONArray) config.get("environments")).size();
-
- for (int i = 0; i < envs; i++) {
- taskIDs.add(i);
- }
-
- return taskIDs;
- }
-
- @Before
- public void setUp() throws Exception {
- JSONArray envs = (JSONArray) config.get("environments");
-
- DesiredCapabilities capabilities = new DesiredCapabilities();
-
- Map envCapabilities = (Map) envs.get(taskID);
- Iterator it = envCapabilities.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pair = (Map.Entry) it.next();
- capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
- }
-
- Map commonCapabilities = (Map) config.get("capabilities");
- it = commonCapabilities.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pair = (Map.Entry) it.next();
- if (capabilities.getCapability(pair.getKey().toString()) == null) {
- capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
- }
- }
-
- String username = System.getenv("BROWSERSTACK_USERNAME");
- if (username == null) {
- username = (String) config.get("username");
- }
-
- String accessKey = System.getenv("BROWSERSTACK_ACCESS_KEY");
- if (accessKey == null) {
- accessKey = (String) config.get("access_key");
- }
-
- String app = System.getenv("BROWSERSTACK_APP_ID");
- if (app != null && !app.isEmpty()) {
- capabilities.setCapability("app", app);
- }
-
- if (capabilities.getCapability("browserstack.local") != null && capabilities.getCapability("browserstack.local") == "true") {
- local = new Local();
- Map options = new HashMap();
- options.put("key", accessKey);
- local.start(options);
- }
-
- driver = new AndroidDriver(new URL("http://" + username + ":" + accessKey + "@" + config.get("server") + "/wd/hub"), capabilities);
- }
-
- @After
- public void tearDown() throws Exception {
- // Invoke driver.quit() to indicate that the test is completed.
- // Otherwise, it will appear as timed out on BrowserStack.
- driver.quit();
- if (local != null) local.stop();
- }
-}
diff --git a/android/junit4-examples/src/test/java/com/browserstack/run_parallel_test/BrowserStackJUnitTest.java b/android/junit4-examples/src/test/java/com/browserstack/run_parallel_test/BrowserStackJUnitTest.java
deleted file mode 100644
index 752f7c1..0000000
--- a/android/junit4-examples/src/test/java/com/browserstack/run_parallel_test/BrowserStackJUnitTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package com.browserstack.run_parallel_test;
-
-import java.net.URL;
-import java.util.Map;
-import java.util.List;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.ArrayList;
-import java.io.FileReader;
-
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-
-import io.appium.java_client.android.AndroidDriver;
-import io.appium.java_client.android.AndroidElement;
-
-import org.openqa.selenium.remote.DesiredCapabilities;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(Parallelized.class)
-public class BrowserStackJUnitTest {
- public AndroidDriver driver;
-
- private static JSONObject config;
-
- @Parameter(value = 0)
- public int taskID;
-
- @Parameters
- public static Iterable extends Object> data() throws Exception {
- List taskIDs = new ArrayList();
-
- JSONParser parser = new JSONParser();
- config = (JSONObject) parser.parse(new FileReader("src/test/resources/com/browserstack/run_parallel_test/parallel.conf.json"));
- int envs = ((JSONArray) config.get("environments")).size();
-
- for (int i = 0; i < envs; i++) {
- taskIDs.add(i);
- }
-
- return taskIDs;
- }
-
- @Before
- public void setUp() throws Exception {
- JSONArray envs = (JSONArray) config.get("environments");
-
- DesiredCapabilities capabilities = new DesiredCapabilities();
-
- Map envCapabilities = (Map) envs.get(taskID);
- Iterator it = envCapabilities.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pair = (Map.Entry) it.next();
- capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
- }
-
- Map commonCapabilities = (Map) config.get("capabilities");
- it = commonCapabilities.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pair = (Map.Entry) it.next();
- if (capabilities.getCapability(pair.getKey().toString()) == null) {
- capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
- }
- }
-
- String username = System.getenv("BROWSERSTACK_USERNAME");
- if (username == null) {
- username = (String) config.get("username");
- }
-
- String accessKey = System.getenv("BROWSERSTACK_ACCESS_KEY");
- if (accessKey == null) {
- accessKey = (String) config.get("access_key");
- }
-
- String app = System.getenv("BROWSERSTACK_APP_ID");
- if (app != null && !app.isEmpty()) {
- capabilities.setCapability("app", app);
- }
-
- driver = new AndroidDriver(new URL("http://" + username + ":" + accessKey + "@" + config.get("server") + "/wd/hub"), capabilities);
- }
-
- @After
- public void tearDown() throws Exception {
- // Invoke driver.quit() to indicate that the test is completed.
- // Otherwise, it will appear as timed out on BrowserStack.
- driver.quit();
- }
-}
diff --git a/android/junit4-examples/src/test/java/com/browserstack/run_parallel_test/ParallelTest.java b/android/junit4-examples/src/test/java/com/browserstack/run_parallel_test/ParallelTest.java
deleted file mode 100644
index c743f30..0000000
--- a/android/junit4-examples/src/test/java/com/browserstack/run_parallel_test/ParallelTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.browserstack.run_parallel_test;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-import java.util.List;
-
-import io.appium.java_client.MobileBy;
-import io.appium.java_client.android.AndroidElement;
-
-import org.openqa.selenium.support.ui.WebDriverWait;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-
-public class ParallelTest extends BrowserStackJUnitTest {
-
- @Test
- public void test() throws Exception {
- AndroidElement searchElement = (AndroidElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Search Wikipedia")));
- searchElement.click();
- AndroidElement insertTextElement = (AndroidElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.id("org.wikipedia.alpha:id/search_src_text")));
- insertTextElement.sendKeys("BrowserStack");
- Thread.sleep(5000);
-
- List allProductsName = driver.findElementsByClassName("android.widget.TextView");
- assertTrue(allProductsName.size() > 0);
- }
-}
diff --git a/android/junit4-examples/src/test/java/com/browserstack/run_parallel_test/Parallelized.java b/android/junit4-examples/src/test/java/com/browserstack/run_parallel_test/Parallelized.java
deleted file mode 100644
index 7529288..0000000
--- a/android/junit4-examples/src/test/java/com/browserstack/run_parallel_test/Parallelized.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.browserstack.run_parallel_test;
-
-import org.junit.runners.Parameterized;
-import org.junit.runners.model.RunnerScheduler;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-public class Parallelized extends Parameterized {
-
- private static class ThreadPoolScheduler implements RunnerScheduler {
- private ExecutorService executor;
-
- public ThreadPoolScheduler() {
- String threads = System.getProperty("junit.parallel.threads", "16");
- int numThreads = Integer.parseInt(threads);
- executor = Executors.newFixedThreadPool(numThreads);
- }
-
- @Override
- public void finished() {
- executor.shutdown();
- try {
- executor.awaitTermination(10, TimeUnit.MINUTES);
- } catch (InterruptedException exc) {
- throw new RuntimeException(exc);
- }
- }
-
- @Override
- public void schedule(Runnable childStatement) {
- executor.submit(childStatement);
- }
- }
-
- public Parallelized(Class klass) throws Throwable {
- super(klass);
- setScheduler(new ThreadPoolScheduler());
- }
-}
diff --git a/android/junit4-examples/src/test/resources/com/browserstack/run_first_test/first.conf.json b/android/junit4-examples/src/test/resources/com/browserstack/run_first_test/first.conf.json
deleted file mode 100644
index 7154d1c..0000000
--- a/android/junit4-examples/src/test/resources/com/browserstack/run_first_test/first.conf.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "server": "hub-cloud.browserstack.com",
- "username": "BROWSERSTACK_USERNAME",
- "access_key": "BROWSERSTACK_ACCESS_KEY",
-
- "capabilities": {
- "project": "First Junit4 Android Project",
- "build": "browserstack-build-1",
- "name": "first_test",
- "browserstack.debug": true,
- "app": "bs://"
- },
-
- "environments": [{
- "device": "Google Pixel 3",
- "os_version": "9.0"
- }]
-}
diff --git a/android/junit4-examples/src/test/resources/com/browserstack/run_local_test/local.conf.json b/android/junit4-examples/src/test/resources/com/browserstack/run_local_test/local.conf.json
deleted file mode 100644
index 78711b0..0000000
--- a/android/junit4-examples/src/test/resources/com/browserstack/run_local_test/local.conf.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "server": "hub-cloud.browserstack.com",
- "username": "BROWSERSTACK_USERNAME",
- "access_key": "BROWSERSTACK_ACCESS_KEY",
-
- "capabilities": {
- "project": "First Junit4 Android Project",
- "build": "browserstack-build-1",
- "name": "local_test",
- "browserstack.debug": true,
- "browserstack.local": true,
- "app": "bs://"
- },
-
- "environments": [{
- "device": "Google Pixel 3",
- "os_version": "9.0"
- }]
-}
diff --git a/android/junit4-examples/src/test/resources/com/browserstack/run_parallel_test/parallel.conf.json b/android/junit4-examples/src/test/resources/com/browserstack/run_parallel_test/parallel.conf.json
deleted file mode 100644
index 01ec31a..0000000
--- a/android/junit4-examples/src/test/resources/com/browserstack/run_parallel_test/parallel.conf.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "server": "hub-cloud.browserstack.com",
- "username": "BROWSERSTACK_USERNAME",
- "access_key": "BROWSERSTACK_ACCESS_KEY",
-
- "capabilities": {
- "project": "First Junit4 Android Project",
- "build": "browserstack-build-1",
- "name": "parallel_test",
- "browserstack.debug": true,
- "app": "bs://"
- },
-
- "environments": [{
- "device": "Google Pixel 3",
- "os_version": "9.0"
- },{
- "device": "Samsung Galaxy S10e",
- "os_version": "9.0"
- }]
-}
diff --git a/android/junit5-examples/src/test/java/com/browserstack/run_first_test/BrowserStackJUnitTest.java b/android/junit5-examples/src/test/java/com/browserstack/run_first_test/BrowserStackJUnitTest.java
deleted file mode 100644
index d2c6b07..0000000
--- a/android/junit5-examples/src/test/java/com/browserstack/run_first_test/BrowserStackJUnitTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package com.browserstack.run_first_test;
-
-import io.appium.java_client.android.AndroidDriver;
-import io.appium.java_client.android.AndroidElement;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-import org.json.simple.parser.ParseException;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-
-import org.junit.jupiter.api.parallel.Execution;
-import org.junit.jupiter.api.parallel.ExecutionMode;
-import org.openqa.selenium.remote.DesiredCapabilities;
-
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Stream;
-
-@Execution(ExecutionMode.CONCURRENT)
-public class BrowserStackJUnitTest {
-
- public AndroidDriver driver;
- public String username;
- public String accessKey;
- public DesiredCapabilities capabilities;
-
- public static JSONObject config;
-
- public static Stream devices() throws IOException, ParseException {
- List taskIDs = new ArrayList();
-
- JSONParser parser = new JSONParser();
- config = (JSONObject) parser.parse(new FileReader("src/test/resources/com/browserstack/run_first_test/first.conf.json"));
- int envs = ((JSONArray) config.get("environments")).size();
-
- for (int i = 0; i < envs; i++) {
- taskIDs.add(i);
- }
-
- return taskIDs.stream();
- }
-
- public void createConnection(int taskId) throws MalformedURLException {
- JSONArray envs = (JSONArray) config.get("environments");
-
- Map envCapabilities = (Map) envs.get(taskId);
- Iterator it = envCapabilities.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pair = (Map.Entry) it.next();
- capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
- }
-
- driver = new AndroidDriver(new URL("http://" + username + ":" + accessKey + "@" + config.get("server") + "/wd/hub"), capabilities);
- }
-
- @BeforeEach
- public void setup() {
- capabilities = new DesiredCapabilities();
-
- Map commonCapabilities = (Map) config.get("capabilities");
- Iterator it = commonCapabilities.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pair = (Map.Entry) it.next();
- if (capabilities.getCapability(pair.getKey().toString()) == null) {
- capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
- }
- }
-
- username = System.getenv("BROWSERSTACK_USERNAME");
- if (username == null) {
- username = (String) config.get("username");
- }
-
- accessKey = System.getenv("BROWSERSTACK_ACCESS_KEY");
- if (accessKey == null) {
- accessKey = (String) config.get("access_key");
- }
-
- String app = System.getenv("BROWSERSTACK_APP_ID");
- if (app != null && !app.isEmpty()) {
- capabilities.setCapability("app", app);
- }
- }
-
- @AfterEach
- public void tearDown() {
- // Invoke driver.quit() to indicate that the test is completed.
- // Otherwise, it will appear as timed out on BrowserStack.
- driver.quit();
- }
-}
diff --git a/android/junit5-examples/src/test/java/com/browserstack/run_first_test/FirstTest.java b/android/junit5-examples/src/test/java/com/browserstack/run_first_test/FirstTest.java
deleted file mode 100644
index 8a4d7f4..0000000
--- a/android/junit5-examples/src/test/java/com/browserstack/run_first_test/FirstTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.browserstack.run_first_test;
-
-import io.appium.java_client.MobileBy;
-import io.appium.java_client.android.AndroidElement;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.MethodSource;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-import org.openqa.selenium.support.ui.WebDriverWait;
-
-import java.io.IOException;
-import java.util.List;
-
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-public class FirstTest extends BrowserStackJUnitTest{
-
- @ParameterizedTest
- @MethodSource("devices")
- void test(int taskId) throws IOException, InterruptedException {
-
- createConnection(taskId);
-
- AndroidElement searchElement = (AndroidElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Search Wikipedia")));
- searchElement.click();
-
- AndroidElement insertTextElement = (AndroidElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.id("org.wikipedia.alpha:id/search_src_text")));
- insertTextElement.sendKeys("BrowserStack");
-
- Thread.sleep(5000);
-
- List allProductsName = driver.findElementsByClassName("android.widget.TextView");
- assertTrue(allProductsName.size() > 0);
- }
-}
diff --git a/android/junit5-examples/src/test/java/com/browserstack/run_local_test/BrowserStackJUnitTest.java b/android/junit5-examples/src/test/java/com/browserstack/run_local_test/BrowserStackJUnitTest.java
deleted file mode 100644
index 2dc17b6..0000000
--- a/android/junit5-examples/src/test/java/com/browserstack/run_local_test/BrowserStackJUnitTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package com.browserstack.run_local_test;
-
-import com.browserstack.local.Local;
-import io.appium.java_client.android.AndroidDriver;
-import io.appium.java_client.android.AndroidElement;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-import org.json.simple.parser.ParseException;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-
-import org.junit.jupiter.api.parallel.Execution;
-import org.junit.jupiter.api.parallel.ExecutionMode;
-import org.openqa.selenium.remote.DesiredCapabilities;
-
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.*;
-import java.util.stream.Stream;
-
-@Execution(ExecutionMode.CONCURRENT)
-public class BrowserStackJUnitTest {
-
- public AndroidDriver driver;
- private Local local;
- public String username;
- public String accessKey;
- public DesiredCapabilities capabilities;
-
- public static JSONObject config;
-
- private static Stream devices() throws IOException, ParseException {
- List taskIDs = new ArrayList();
-
- JSONParser parser = new JSONParser();
- config = (JSONObject) parser.parse(new FileReader("src/test/resources/com/browserstack/run_local_test/local.conf.json"));
- int envs = ((JSONArray) config.get("environments")).size();
-
- for (int i = 0; i < envs; i++) {
- taskIDs.add(i);
- }
-
- return taskIDs.stream();
- }
-
- public void createConnection(int taskId) throws MalformedURLException {
- JSONArray envs = (JSONArray) config.get("environments");
-
- Map envCapabilities = (Map) envs.get(taskId);
- Iterator it = envCapabilities.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pair = (Map.Entry)it.next();
- capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
- }
-
- driver = new AndroidDriver(new URL("http://" + username + ":" + accessKey + "@" + config.get("server")+"/wd/hub"), capabilities);
- }
-
- @BeforeEach
- public void setup() throws Exception {
- capabilities = new DesiredCapabilities();
-
- Map commonCapabilities = (Map) config.get("capabilities");
- Iterator it = commonCapabilities.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pair = (Map.Entry)it.next();
- if(capabilities.getCapability(pair.getKey().toString()) == null){
- capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
- }
- }
-
- username = System.getenv("BROWSERSTACK_USERNAME");
- if(username == null) {
- username = (String) config.get("username");
- }
-
- accessKey = System.getenv("BROWSERSTACK_ACCESS_KEY");
- if(accessKey == null) {
- accessKey = (String) config.get("access_key");
- }
-
- String app = System.getenv("BROWSERSTACK_APP_ID");
- if(app != null && !app.isEmpty()) {
- capabilities.setCapability("app", app);
- }
-
- if(capabilities.getCapability("browserstack.local") != null && capabilities.getCapability("browserstack.local") == "true"){
- local = new Local();
- Map options = new HashMap();
- options.put("key", accessKey);
- local.start(options);
- }
- }
-
- @AfterEach
- public void tearDown() throws Exception {
- // Invoke driver.quit() to indicate that the test is completed.
- // Otherwise, it will appear as timed out on BrowserStack.
- driver.quit();
- if(local != null) local.stop();
- }
-}
diff --git a/android/junit5-examples/src/test/java/com/browserstack/run_parallel_test/BrowserStackJUnitTest.java b/android/junit5-examples/src/test/java/com/browserstack/run_parallel_test/BrowserStackJUnitTest.java
deleted file mode 100644
index ee4a97b..0000000
--- a/android/junit5-examples/src/test/java/com/browserstack/run_parallel_test/BrowserStackJUnitTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-package com.browserstack.run_parallel_test;
-
-import io.appium.java_client.android.AndroidDriver;
-import io.appium.java_client.android.AndroidElement;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-import org.json.simple.parser.ParseException;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-
-import org.junit.jupiter.api.parallel.Execution;
-import org.junit.jupiter.api.parallel.ExecutionMode;
-import org.openqa.selenium.remote.DesiredCapabilities;
-
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.*;
-import java.util.stream.Stream;
-
-@Execution(ExecutionMode.CONCURRENT)
-public class BrowserStackJUnitTest {
-
- public AndroidDriver driver;
- public String username;
- public String accessKey;
- public DesiredCapabilities capabilities;
-
- public static JSONObject config;
-
- private static Stream devices() throws IOException, ParseException {
- List taskIDs = new ArrayList();
-
- JSONParser parser = new JSONParser();
- config = (JSONObject) parser.parse(new FileReader("src/test/resources/com/browserstack/run_parallel_test/parallel.conf.json"));
- int envs = ((JSONArray) config.get("environments")).size();
-
- for (int i = 0; i < envs; i++) {
- taskIDs.add(i);
- }
-
- return taskIDs.stream();
- }
-
- public void createConnection(int taskId) throws MalformedURLException {
- JSONArray envs = (JSONArray) config.get("environments");
-
- Map envCapabilities = (Map) envs.get(taskId);
- Iterator it = envCapabilities.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pair = (Map.Entry)it.next();
- capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
- }
-
- driver = new AndroidDriver(new URL("http://" + username + ":" + accessKey + "@" + config.get("server")+"/wd/hub"), capabilities);
- }
-
- @BeforeEach
- public void setup() {
- capabilities = new DesiredCapabilities();
-
- Map commonCapabilities = (Map) config.get("capabilities");
- Iterator it = commonCapabilities.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pair = (Map.Entry)it.next();
- if(capabilities.getCapability(pair.getKey().toString()) == null){
- capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
- }
- }
-
- username = System.getenv("BROWSERSTACK_USERNAME");
- if(username == null) {
- username = (String) config.get("username");
- }
-
- accessKey = System.getenv("BROWSERSTACK_ACCESS_KEY");
- if(accessKey == null) {
- accessKey = (String) config.get("access_key");
- }
-
- String app = System.getenv("BROWSERSTACK_APP_ID");
- if(app != null && !app.isEmpty()) {
- capabilities.setCapability("app", app);
- }
- }
-
- @AfterEach
- public void tearDown() {
- // Invoke driver.quit() to indicate that the test is completed.
- // Otherwise, it will appear as timed out on BrowserStack.
- driver.quit();
- }
-}
diff --git a/android/junit5-examples/src/test/java/com/browserstack/run_parallel_test/ParallelTest.java b/android/junit5-examples/src/test/java/com/browserstack/run_parallel_test/ParallelTest.java
deleted file mode 100644
index 6a4fadd..0000000
--- a/android/junit5-examples/src/test/java/com/browserstack/run_parallel_test/ParallelTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.browserstack.run_parallel_test;
-
-import io.appium.java_client.MobileBy;
-import io.appium.java_client.android.AndroidElement;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.MethodSource;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-import org.openqa.selenium.support.ui.WebDriverWait;
-
-import java.io.IOException;
-import java.util.List;
-
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-public class ParallelTest extends BrowserStackJUnitTest {
-
- @ParameterizedTest
- @MethodSource("devices")
- void test(int taskId) throws IOException, InterruptedException {
-
- createConnection(taskId);
-
- AndroidElement searchElement = (AndroidElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Search Wikipedia")));
- searchElement.click();
- AndroidElement insertTextElement = (AndroidElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.id("org.wikipedia.alpha:id/search_src_text")));
- insertTextElement.sendKeys("BrowserStack");
- Thread.sleep(5000);
-
- List allProductsName = driver.findElementsByClassName("android.widget.TextView");
- assertTrue(allProductsName.size() > 0);
-
- }
-}
diff --git a/android/junit5-examples/src/test/resources/com/browserstack/run_first_test/first.conf.json b/android/junit5-examples/src/test/resources/com/browserstack/run_first_test/first.conf.json
deleted file mode 100644
index 88dad1e..0000000
--- a/android/junit5-examples/src/test/resources/com/browserstack/run_first_test/first.conf.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "server": "hub-cloud.browserstack.com",
- "username": "BROWSERSTACK_USERNAME",
- "access_key": "BROWSERSTACK_ACCESS_KEY",
-
- "capabilities": {
- "project": "First Junit5 Android Project",
- "build": "browserstack-build-1",
- "name": "first_test",
- "browserstack.debug": true,
- "app": "bs://"
- },
-
- "environments": [{
- "device": "Google Pixel 3",
- "os_version": "9.0"
- }]
-}
diff --git a/android/junit5-examples/src/test/resources/com/browserstack/run_local_test/local.conf.json b/android/junit5-examples/src/test/resources/com/browserstack/run_local_test/local.conf.json
deleted file mode 100644
index bf19ce2..0000000
--- a/android/junit5-examples/src/test/resources/com/browserstack/run_local_test/local.conf.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "server": "hub-cloud.browserstack.com",
- "username": "BROWSERSTACK_USERNAME",
- "access_key": "BROWSERSTACK_ACCESS_KEY",
-
- "capabilities": {
- "project": "First Junit5 Android Project",
- "build": "browserstack-build-1",
- "name": "local_test",
- "browserstack.debug": true,
- "browserstack.local": true,
- "app": "bs://"
- },
-
- "environments": [{
- "device": "Google Pixel 3",
- "os_version": "9.0"
- }]
-}
diff --git a/android/junit5-examples/src/test/resources/com/browserstack/run_parallel_test/parallel.conf.json b/android/junit5-examples/src/test/resources/com/browserstack/run_parallel_test/parallel.conf.json
deleted file mode 100644
index 5a5a6ec..0000000
--- a/android/junit5-examples/src/test/resources/com/browserstack/run_parallel_test/parallel.conf.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "server": "hub-cloud.browserstack.com",
- "username": "BROWSERSTACK_USERNAME",
- "access_key": "BROWSERSTACK_ACCESS_KEY",
-
- "capabilities": {
- "project": "First Junit5 Android Project",
- "build": "browserstack-build-1",
- "name": "parallel_test",
- "browserstack.debug": true,
- "app": "bs://"
- },
-
- "environments": [{
- "device": "Google Pixel 3",
- "os_version": "9.0"
- },{
- "device": "Samsung Galaxy S10e",
- "os_version": "9.0"
- }]
-}
diff --git a/ios/junit4-examples/pom.xml b/ios/junit4-examples/pom.xml
deleted file mode 100644
index 3e0ff5f..0000000
--- a/ios/junit4-examples/pom.xml
+++ /dev/null
@@ -1,126 +0,0 @@
-
- 4.0.0
-
- com.browserstack
- junit4-browserstack
- 1.0-SNAPSHOT
- jar
-
- junit-browserstack
- https://www.github.com/browserstack/junit-appium-app-browserstack
-
-
- UTF-8
- 2.19.1
-
-
- default
-
-
-
-
- junit
- junit
- 4.12
-
-
- commons-io
- commons-io
- 1.3.2
-
-
- org.seleniumhq.selenium
- selenium-java
- 3.141.59
-
-
- io.appium
- java-client
- 7.0.0
-
-
- com.browserstack
- browserstack-local-java
- 1.0.3
-
-
- com.googlecode.json-simple
- json-simple
- 1.1.1
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 2.22.2
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.8.1
-
- 1.8
- 1.8
-
-
-
-
-
-
-
- first
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- com/browserstack/run_first_test/FirstTest.java
-
-
-
-
-
-
-
-
- local
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- com/browserstack/run_local_test/LocalTest.java
-
-
-
-
-
-
-
-
- parallel
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- com/browserstack/run_parallel_test/ParallelTest.java
-
-
-
-
-
-
-
-
-
diff --git a/ios/junit4-examples/src/test/java/com/browserstack/run_first_test/BrowserStackJUnitTest.java b/ios/junit4-examples/src/test/java/com/browserstack/run_first_test/BrowserStackJUnitTest.java
deleted file mode 100644
index f40cf4b..0000000
--- a/ios/junit4-examples/src/test/java/com/browserstack/run_first_test/BrowserStackJUnitTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-package com.browserstack.run_first_test;
-
-import java.net.URL;
-import java.util.Map;
-import java.util.List;
-import java.util.Iterator;
-import java.util.ArrayList;
-import java.io.FileReader;
-
-import io.appium.java_client.ios.IOSDriver;
-import io.appium.java_client.ios.IOSElement;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-
-import org.junit.runners.Parameterized;
-import org.openqa.selenium.remote.DesiredCapabilities;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(Parameterized.class)
-public class BrowserStackJUnitTest {
- public IOSDriver driver;
-
- private static JSONObject config;
-
- @Parameter(value = 0)
- public int taskID;
-
- @Parameters
- public static Iterable extends Object> data() throws Exception {
- List taskIDs = new ArrayList();
-
- JSONParser parser = new JSONParser();
- config = (JSONObject) parser.parse(new FileReader("src/test/resources/com/browserstack/run_first_test/first.conf.json"));
- int envs = ((JSONArray) config.get("environments")).size();
-
- for (int i = 0; i < envs; i++) {
- taskIDs.add(i);
- }
-
- return taskIDs;
- }
-
- @Before
- public void setUp() throws Exception {
- JSONArray envs = (JSONArray) config.get("environments");
-
- DesiredCapabilities capabilities = new DesiredCapabilities();
-
- Map envCapabilities = (Map) envs.get(taskID);
- Iterator it = envCapabilities.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pair = (Map.Entry) it.next();
- capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
- }
-
- Map commonCapabilities = (Map) config.get("capabilities");
- it = commonCapabilities.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pair = (Map.Entry) it.next();
- if (capabilities.getCapability(pair.getKey().toString()) == null) {
- capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
- }
- }
-
- String username = System.getenv("BROWSERSTACK_USERNAME");
- if (username == null) {
- username = (String) config.get("username");
- }
-
- String accessKey = System.getenv("BROWSERSTACK_ACCESS_KEY");
- if (accessKey == null) {
- accessKey = (String) config.get("access_key");
- }
-
- String app = System.getenv("BROWSERSTACK_APP_ID");
- if (app != null && !app.isEmpty()) {
- capabilities.setCapability("app", app);
- }
-
- driver = new IOSDriver(new URL("http://" + username + ":" + accessKey + "@" + config.get("server") + "/wd/hub"), capabilities);
- }
-
- @After
- public void tearDown() throws Exception {
- // Invoke driver.quit() to indicate that the test is completed.
- // Otherwise, it will appear as timed out on BrowserStack.
- driver.quit();
- }
-}
diff --git a/ios/junit4-examples/src/test/java/com/browserstack/run_first_test/FirstTest.java b/ios/junit4-examples/src/test/java/com/browserstack/run_first_test/FirstTest.java
deleted file mode 100644
index 7b0e4af..0000000
--- a/ios/junit4-examples/src/test/java/com/browserstack/run_first_test/FirstTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.browserstack.run_first_test;
-
-import static org.junit.Assert.*;
-
-import io.appium.java_client.ios.IOSElement;
-import org.junit.Test;
-
-import io.appium.java_client.MobileBy;
-
-import org.openqa.selenium.support.ui.WebDriverWait;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-
-public class FirstTest extends BrowserStackJUnitTest {
-
- @Test
- public void test() throws Exception {
- IOSElement textButton = (IOSElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Text Button")));
- textButton.click();
- IOSElement textInput = (IOSElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Text Input")));
- textInput.sendKeys("hello@browserstack.com" + "\n");
-
- Thread.sleep(5000);
-
- IOSElement textOutput = (IOSElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Text Output")));
-
- assertEquals(textOutput.getText(),"hello@browserstack.com");
- }
-}
diff --git a/ios/junit4-examples/src/test/java/com/browserstack/run_local_test/BrowserStackJUnitTest.java b/ios/junit4-examples/src/test/java/com/browserstack/run_local_test/BrowserStackJUnitTest.java
deleted file mode 100644
index 89467ad..0000000
--- a/ios/junit4-examples/src/test/java/com/browserstack/run_local_test/BrowserStackJUnitTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package com.browserstack.run_local_test;
-
-import com.browserstack.local.Local;
-
-import java.net.URL;
-import java.util.Map;
-import java.util.List;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.ArrayList;
-import java.io.FileReader;
-
-import io.appium.java_client.ios.IOSDriver;
-import io.appium.java_client.ios.IOSElement;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-
-import org.junit.runners.Parameterized;
-import org.openqa.selenium.remote.DesiredCapabilities;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(Parameterized.class)
-public class BrowserStackJUnitTest {
- public IOSDriver driver;
- private Local local;
-
- private static JSONObject config;
-
- @Parameter(value = 0)
- public int taskID;
-
- @Parameters
- public static Iterable extends Object> data() throws Exception {
- List taskIDs = new ArrayList();
-
- JSONParser parser = new JSONParser();
- config = (JSONObject) parser.parse(new FileReader("src/test/resources/com/browserstack/run_local_test/local.conf.json"));
- int envs = ((JSONArray) config.get("environments")).size();
-
- for (int i = 0; i < envs; i++) {
- taskIDs.add(i);
- }
-
- return taskIDs;
- }
-
- @Before
- public void setUp() throws Exception {
- JSONArray envs = (JSONArray) config.get("environments");
-
- DesiredCapabilities capabilities = new DesiredCapabilities();
-
- Map envCapabilities = (Map) envs.get(taskID);
- Iterator it = envCapabilities.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pair = (Map.Entry) it.next();
- capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
- }
-
- Map commonCapabilities = (Map) config.get("capabilities");
- it = commonCapabilities.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pair = (Map.Entry) it.next();
- if (capabilities.getCapability(pair.getKey().toString()) == null) {
- capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
- }
- }
-
- String username = System.getenv("BROWSERSTACK_USERNAME");
- if (username == null) {
- username = (String) config.get("username");
- }
-
- String accessKey = System.getenv("BROWSERSTACK_ACCESS_KEY");
- if (accessKey == null) {
- accessKey = (String) config.get("access_key");
- }
-
- String app = System.getenv("BROWSERSTACK_APP_ID");
- if (app != null && !app.isEmpty()) {
- capabilities.setCapability("app", app);
- }
-
- if (capabilities.getCapability("browserstack.local") != null && capabilities.getCapability("browserstack.local") == "true") {
- local = new Local();
- Map options = new HashMap();
- options.put("key", accessKey);
- local.start(options);
- }
-
- driver = new IOSDriver(new URL("http://" + username + ":" + accessKey + "@" + config.get("server") + "/wd/hub"), capabilities);
- }
-
- @After
- public void tearDown() throws Exception {
- // Invoke driver.quit() to indicate that the test is completed.
- // Otherwise, it will appear as timed out on BrowserStack.
- driver.quit();
- if (local != null) local.stop();
- }
-}
diff --git a/ios/junit4-examples/src/test/java/com/browserstack/run_parallel_test/BrowserStackJUnitTest.java b/ios/junit4-examples/src/test/java/com/browserstack/run_parallel_test/BrowserStackJUnitTest.java
deleted file mode 100644
index 33b3619..0000000
--- a/ios/junit4-examples/src/test/java/com/browserstack/run_parallel_test/BrowserStackJUnitTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package com.browserstack.run_parallel_test;
-
-import java.net.URL;
-import java.util.Map;
-import java.util.List;
-import java.util.Iterator;
-import java.util.ArrayList;
-import java.io.FileReader;
-
-import io.appium.java_client.ios.IOSDriver;
-import io.appium.java_client.ios.IOSElement;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-
-import org.openqa.selenium.remote.DesiredCapabilities;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(Parallelized.class)
-public class BrowserStackJUnitTest {
- public IOSDriver driver;
- private static JSONObject config;
-
- @Parameter(value = 0)
- public int taskID;
-
- @Parameters
- public static Iterable extends Object> data() throws Exception {
- List taskIDs = new ArrayList();
-
- JSONParser parser = new JSONParser();
- config = (JSONObject) parser.parse(new FileReader("src/test/resources/com/browserstack/run_parallel_test/parallel.conf.json"));
- int envs = ((JSONArray) config.get("environments")).size();
-
- for (int i = 0; i < envs; i++) {
- taskIDs.add(i);
- }
-
- return taskIDs;
- }
-
- @Before
- public void setUp() throws Exception {
- JSONArray envs = (JSONArray) config.get("environments");
-
- DesiredCapabilities capabilities = new DesiredCapabilities();
-
- Map envCapabilities = (Map) envs.get(taskID);
- Iterator it = envCapabilities.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pair = (Map.Entry) it.next();
- capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
- }
-
- Map commonCapabilities = (Map) config.get("capabilities");
- it = commonCapabilities.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pair = (Map.Entry) it.next();
- if (capabilities.getCapability(pair.getKey().toString()) == null) {
- capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
- }
- }
-
- String username = System.getenv("BROWSERSTACK_USERNAME");
- if (username == null) {
- username = (String) config.get("username");
- }
-
- String accessKey = System.getenv("BROWSERSTACK_ACCESS_KEY");
- if (accessKey == null) {
- accessKey = (String) config.get("access_key");
- }
-
- String app = System.getenv("BROWSERSTACK_APP_ID");
- if (app != null && !app.isEmpty()) {
- capabilities.setCapability("app", app);
- }
-
- driver = new IOSDriver(new URL("http://" + username + ":" + accessKey + "@" + config.get("server") + "/wd/hub"), capabilities);
- }
-
- @After
- public void tearDown() throws Exception {
- // Invoke driver.quit() to indicate that the test is completed.
- // Otherwise, it will appear as timed out on BrowserStack.
- driver.quit();
- }
-}
diff --git a/ios/junit4-examples/src/test/java/com/browserstack/run_parallel_test/ParallelTest.java b/ios/junit4-examples/src/test/java/com/browserstack/run_parallel_test/ParallelTest.java
deleted file mode 100644
index 44627e3..0000000
--- a/ios/junit4-examples/src/test/java/com/browserstack/run_parallel_test/ParallelTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.browserstack.run_parallel_test;
-
-import static org.junit.Assert.*;
-
-import io.appium.java_client.ios.IOSElement;
-import org.junit.Test;
-
-import io.appium.java_client.MobileBy;
-
-import org.openqa.selenium.support.ui.WebDriverWait;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-
-public class ParallelTest extends BrowserStackJUnitTest {
-
- @Test
- public void test() throws Exception {
- IOSElement textButton = (IOSElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Text Button")));
- textButton.click();
- IOSElement textInput = (IOSElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Text Input")));
- textInput.sendKeys("hello@browserstack.com" + "\n");
-
- Thread.sleep(5000);
-
- IOSElement textOutput = (IOSElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Text Output")));
-
- assertEquals(textOutput.getText(),"hello@browserstack.com");
- }
-}
diff --git a/ios/junit4-examples/src/test/java/com/browserstack/run_parallel_test/Parallelized.java b/ios/junit4-examples/src/test/java/com/browserstack/run_parallel_test/Parallelized.java
deleted file mode 100644
index 7529288..0000000
--- a/ios/junit4-examples/src/test/java/com/browserstack/run_parallel_test/Parallelized.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.browserstack.run_parallel_test;
-
-import org.junit.runners.Parameterized;
-import org.junit.runners.model.RunnerScheduler;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-public class Parallelized extends Parameterized {
-
- private static class ThreadPoolScheduler implements RunnerScheduler {
- private ExecutorService executor;
-
- public ThreadPoolScheduler() {
- String threads = System.getProperty("junit.parallel.threads", "16");
- int numThreads = Integer.parseInt(threads);
- executor = Executors.newFixedThreadPool(numThreads);
- }
-
- @Override
- public void finished() {
- executor.shutdown();
- try {
- executor.awaitTermination(10, TimeUnit.MINUTES);
- } catch (InterruptedException exc) {
- throw new RuntimeException(exc);
- }
- }
-
- @Override
- public void schedule(Runnable childStatement) {
- executor.submit(childStatement);
- }
- }
-
- public Parallelized(Class klass) throws Throwable {
- super(klass);
- setScheduler(new ThreadPoolScheduler());
- }
-}
diff --git a/ios/junit4-examples/src/test/resources/com/browserstack/run_first_test/first.conf.json b/ios/junit4-examples/src/test/resources/com/browserstack/run_first_test/first.conf.json
deleted file mode 100644
index b318b10..0000000
--- a/ios/junit4-examples/src/test/resources/com/browserstack/run_first_test/first.conf.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "server": "hub-cloud.browserstack.com",
- "username": "BROWSERSTACK_USERNAME",
- "access_key": "BROWSERSTACK_ACCESS_KEY",
-
- "capabilities": {
- "project": "First Junit4 iOS Project",
- "build": "browserstack-build-1",
- "name": "first_test",
- "browserstack.debug": true,
- "app": "bs://"
- },
-
- "environments": [{
- "device": "iPhone 11 Pro",
- "os_version": "13"
- }]
-}
diff --git a/ios/junit4-examples/src/test/resources/com/browserstack/run_local_test/local.conf.json b/ios/junit4-examples/src/test/resources/com/browserstack/run_local_test/local.conf.json
deleted file mode 100644
index f644171..0000000
--- a/ios/junit4-examples/src/test/resources/com/browserstack/run_local_test/local.conf.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "server": "hub-cloud.browserstack.com",
- "username": "BROWSERSTACK_USERNAME",
- "access_key": "BROWSERSTACK_ACCESS_KEY",
-
- "capabilities": {
- "project": "First Junit4 iOS Project",
- "build": "browserstack-build-1",
- "name": "local_test",
- "browserstack.debug": true,
- "browserstack.local": true,
- "app": "bs://"
- },
-
- "environments": [{
- "device": "iPhone 11 Pro",
- "os_version": "13"
- }]
-}
diff --git a/ios/junit4-examples/src/test/resources/com/browserstack/run_parallel_test/parallel.conf.json b/ios/junit4-examples/src/test/resources/com/browserstack/run_parallel_test/parallel.conf.json
deleted file mode 100644
index 801e7fa..0000000
--- a/ios/junit4-examples/src/test/resources/com/browserstack/run_parallel_test/parallel.conf.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "server": "hub-cloud.browserstack.com",
- "username": "BROWSERSTACK_USERNAME",
- "access_key": "BROWSERSTACK_ACCESS_KEY",
-
- "capabilities": {
- "project": "First Junit4 iOS Project",
- "build": "browserstack-build-1",
- "name": "parallel_test",
- "browserstack.debug": true,
- "app": "bs://"
- },
-
- "environments": [{
- "device": "iPhone 11 Pro",
- "os_version": "13"
- }, {
- "device": "iPhone 11 Pro Max",
- "os_version": "13"
- }]
-}
diff --git a/ios/junit5-examples/src/test/java/com/browserstack/run_first_test/BrowserStackJUnitTest.java b/ios/junit5-examples/src/test/java/com/browserstack/run_first_test/BrowserStackJUnitTest.java
deleted file mode 100644
index 5637475..0000000
--- a/ios/junit5-examples/src/test/java/com/browserstack/run_first_test/BrowserStackJUnitTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package com.browserstack.run_first_test;
-
-import io.appium.java_client.ios.IOSDriver;
-import io.appium.java_client.ios.IOSElement;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-import org.json.simple.parser.ParseException;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-
-import org.junit.jupiter.api.parallel.Execution;
-import org.junit.jupiter.api.parallel.ExecutionMode;
-import org.openqa.selenium.remote.DesiredCapabilities;
-
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Stream;
-
-@Execution(ExecutionMode.CONCURRENT)
-public class BrowserStackJUnitTest {
-
- public IOSDriver driver;
- public String username;
- public String accessKey;
- public DesiredCapabilities capabilities;
-
- public static JSONObject config;
-
-
- private static Stream devices() throws IOException, ParseException {
-
- List taskIDs = new ArrayList();
-
- JSONParser parser = new JSONParser();
- config = (JSONObject) parser.parse(new FileReader("src/test/resources/com/browserstack/run_first_test/first.conf.json"));
- int envs = ((JSONArray) config.get("environments")).size();
-
- for (int i = 0; i < envs; i++) {
- taskIDs.add(i);
- }
-
- return taskIDs.stream();
- }
-
- public void createConnection(int taskId) throws MalformedURLException {
- JSONArray envs = (JSONArray) config.get("environments");
-
- Map envCapabilities = (Map) envs.get(taskId);
- Iterator it = envCapabilities.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pair = (Map.Entry) it.next();
- capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
- }
-
- driver = new IOSDriver(new URL("http://" + username + ":" + accessKey + "@" + config.get("server") + "/wd/hub"), capabilities);
- }
-
- @BeforeEach
- public void setup() {
- capabilities = new DesiredCapabilities();
-
- Map commonCapabilities = (Map) config.get("capabilities");
- Iterator it = commonCapabilities.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pair = (Map.Entry) it.next();
- if (capabilities.getCapability(pair.getKey().toString()) == null) {
- capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
- }
- }
-
- username = System.getenv("BROWSERSTACK_USERNAME");
- if (username == null) {
- username = (String) config.get("username");
- }
-
- accessKey = System.getenv("BROWSERSTACK_ACCESS_KEY");
- if (accessKey == null) {
- accessKey = (String) config.get("access_key");
- }
-
- String app = System.getenv("BROWSERSTACK_APP_ID");
- if (app != null && !app.isEmpty()) {
- capabilities.setCapability("app", app);
- }
- }
-
- @AfterEach
- public void tearDown() {
- // Invoke driver.quit() to indicate that the test is completed.
- // Otherwise, it will appear as timed out on BrowserStack.
- driver.quit();
- }
-}
diff --git a/ios/junit5-examples/src/test/java/com/browserstack/run_first_test/FirstTest.java b/ios/junit5-examples/src/test/java/com/browserstack/run_first_test/FirstTest.java
deleted file mode 100644
index fbf09cd..0000000
--- a/ios/junit5-examples/src/test/java/com/browserstack/run_first_test/FirstTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.browserstack.run_first_test;
-
-import io.appium.java_client.MobileBy;
-import io.appium.java_client.ios.IOSElement;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.MethodSource;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-import org.openqa.selenium.support.ui.WebDriverWait;
-
-import java.io.IOException;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-public class FirstTest extends BrowserStackJUnitTest{
-
- @ParameterizedTest
- @MethodSource("devices")
- void testCalcOne(int taskId) throws IOException, InterruptedException {
-
- createConnection(taskId);
-
- IOSElement textButton = (IOSElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Text Button")));
- textButton.click();
- IOSElement textInput = (IOSElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Text Input")));
- textInput.sendKeys("hello@browserstack.com"+"\n");
-
- Thread.sleep(5000);
-
- IOSElement textOutput = (IOSElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Text Output")));
-
- assertEquals(textOutput.getText(),"hello@browserstack.com");
- }
-}
diff --git a/ios/junit5-examples/src/test/java/com/browserstack/run_local_test/BrowserStackJUnitTest.java b/ios/junit5-examples/src/test/java/com/browserstack/run_local_test/BrowserStackJUnitTest.java
deleted file mode 100644
index 016ab31..0000000
--- a/ios/junit5-examples/src/test/java/com/browserstack/run_local_test/BrowserStackJUnitTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package com.browserstack.run_local_test;
-
-import com.browserstack.local.Local;
-import io.appium.java_client.ios.IOSDriver;
-import io.appium.java_client.ios.IOSElement;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-import org.json.simple.parser.ParseException;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-
-import org.junit.jupiter.api.parallel.Execution;
-import org.junit.jupiter.api.parallel.ExecutionMode;
-import org.openqa.selenium.remote.DesiredCapabilities;
-
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.*;
-import java.util.stream.Stream;
-
-@Execution(ExecutionMode.CONCURRENT)
-public class BrowserStackJUnitTest {
-
- public IOSDriver driver;
- private Local local;
- public String username;
- public String accessKey;
- public DesiredCapabilities capabilities;
-
- public static JSONObject config;
-
- private static Stream devices() throws IOException, ParseException {
-
- List taskIDs = new ArrayList();
-
- JSONParser parser = new JSONParser();
- config = (JSONObject) parser.parse(new FileReader("src/test/resources/com/browserstack/run_local_test/local.conf.json"));
- int envs = ((JSONArray) config.get("environments")).size();
-
- for (int i = 0; i < envs; i++) {
- taskIDs.add(i);
- }
-
- return taskIDs.stream();
- }
-
- public void createConnection(int taskId) throws MalformedURLException {
- JSONArray envs = (JSONArray) config.get("environments");
-
- Map envCapabilities = (Map) envs.get(taskId);
- Iterator it = envCapabilities.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pair = (Map.Entry) it.next();
- capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
- }
-
- driver = new IOSDriver(new URL("http://" + username + ":" + accessKey + "@" + config.get("server") + "/wd/hub"), capabilities);
- }
-
- @BeforeEach
- public void setup() throws Exception {
- capabilities = new DesiredCapabilities();
-
- Map commonCapabilities = (Map) config.get("capabilities");
- Iterator it = commonCapabilities.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pair = (Map.Entry) it.next();
- if (capabilities.getCapability(pair.getKey().toString()) == null) {
- capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
- }
- }
-
- username = System.getenv("BROWSERSTACK_USERNAME");
- if (username == null) {
- username = (String) config.get("username");
- }
-
- accessKey = System.getenv("BROWSERSTACK_ACCESS_KEY");
- if (accessKey == null) {
- accessKey = (String) config.get("access_key");
- }
-
- String app = System.getenv("BROWSERSTACK_APP_ID");
- if (app != null && !app.isEmpty()) {
- capabilities.setCapability("app", app);
- }
-
- if (capabilities.getCapability("browserstack.local") != null && capabilities.getCapability("browserstack.local") == "true") {
- local = new Local();
- Map options = new HashMap();
- options.put("key", accessKey);
- local.start(options);
- }
- }
-
- @AfterEach
- public void tearDown() throws Exception {
- // Invoke driver.quit() to indicate that the test is completed.
- // Otherwise, it will appear as timed out on BrowserStack.
- driver.quit();
- if (local != null) local.stop();
- }
-}
diff --git a/ios/junit5-examples/src/test/java/com/browserstack/run_parallel_test/BrowserStackJUnitTest.java b/ios/junit5-examples/src/test/java/com/browserstack/run_parallel_test/BrowserStackJUnitTest.java
deleted file mode 100644
index 41cbcc9..0000000
--- a/ios/junit5-examples/src/test/java/com/browserstack/run_parallel_test/BrowserStackJUnitTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package com.browserstack.run_parallel_test;
-
-import io.appium.java_client.ios.IOSDriver;
-import io.appium.java_client.ios.IOSElement;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-import org.json.simple.parser.ParseException;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-
-import org.junit.jupiter.api.parallel.Execution;
-import org.junit.jupiter.api.parallel.ExecutionMode;
-import org.openqa.selenium.remote.DesiredCapabilities;
-
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.*;
-import java.util.stream.Stream;
-
-@Execution(ExecutionMode.CONCURRENT)
-public class BrowserStackJUnitTest {
-
- public IOSDriver driver;
- public String username;
- public String accessKey;
- public DesiredCapabilities capabilities;
-
- public static JSONObject config;
-
- private static Stream devices() throws IOException, ParseException {
-
- List taskIDs = new ArrayList();
-
- JSONParser parser = new JSONParser();
- config = (JSONObject) parser.parse(new FileReader("src/test/resources/com/browserstack/run_parallel_test/parallel.conf.json"));
- int envs = ((JSONArray) config.get("environments")).size();
-
- for (int i = 0; i < envs; i++) {
- taskIDs.add(i);
- }
-
- return taskIDs.stream();
- }
-
- public void createConnection(int taskId) throws MalformedURLException {
- JSONArray envs = (JSONArray) config.get("environments");
-
- Map envCapabilities = (Map) envs.get(taskId);
- Iterator it = envCapabilities.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pair = (Map.Entry) it.next();
- capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
- }
-
- driver = new IOSDriver(new URL("http://" + username + ":" + accessKey + "@" + config.get("server") + "/wd/hub"), capabilities);
- }
-
- @BeforeEach
- public void setup() {
- capabilities = new DesiredCapabilities();
-
- Map commonCapabilities = (Map) config.get("capabilities");
- Iterator it = commonCapabilities.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry pair = (Map.Entry) it.next();
- if (capabilities.getCapability(pair.getKey().toString()) == null) {
- capabilities.setCapability(pair.getKey().toString(), pair.getValue().toString());
- }
- }
-
- username = System.getenv("BROWSERSTACK_USERNAME");
- if (username == null) {
- username = (String) config.get("username");
- }
-
- accessKey = System.getenv("BROWSERSTACK_ACCESS_KEY");
- if (accessKey == null) {
- accessKey = (String) config.get("access_key");
- }
-
- String app = System.getenv("BROWSERSTACK_APP_ID");
- if (app != null && !app.isEmpty()) {
- capabilities.setCapability("app", app);
- }
- }
-
- @AfterEach
- public void tearDown() {
- // Invoke driver.quit() to indicate that the test is completed.
- // Otherwise, it will appear as timed out on BrowserStack.
- driver.quit();
- }
-}
diff --git a/ios/junit5-examples/src/test/java/com/browserstack/run_parallel_test/ParallelTest.java b/ios/junit5-examples/src/test/java/com/browserstack/run_parallel_test/ParallelTest.java
deleted file mode 100644
index a6ceea8..0000000
--- a/ios/junit5-examples/src/test/java/com/browserstack/run_parallel_test/ParallelTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.browserstack.run_parallel_test;
-
-import io.appium.java_client.MobileBy;
-import io.appium.java_client.ios.IOSElement;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.MethodSource;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-import org.openqa.selenium.support.ui.WebDriverWait;
-
-import java.io.IOException;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-public class ParallelTest extends BrowserStackJUnitTest {
-
- @ParameterizedTest
- @MethodSource("devices")
- void testCalcOne(int taskId) throws IOException, InterruptedException {
-
- createConnection(taskId);
-
- IOSElement textButton = (IOSElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Text Button")));
- textButton.click();
- IOSElement textInput = (IOSElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Text Input")));
- textInput.sendKeys("hello@browserstack.com"+"\n");
-
- Thread.sleep(5000);
-
- IOSElement textOutput = (IOSElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Text Output")));
-
- assertEquals(textOutput.getText(),"hello@browserstack.com");
- }
-}
diff --git a/ios/junit5-examples/src/test/resources/com/browserstack/run_first_test/first.conf.json b/ios/junit5-examples/src/test/resources/com/browserstack/run_first_test/first.conf.json
deleted file mode 100644
index c832ee0..0000000
--- a/ios/junit5-examples/src/test/resources/com/browserstack/run_first_test/first.conf.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "server": "hub-cloud.browserstack.com",
- "username": "BROWSERSTACK_USERNAME",
- "access_key": "BROWSERSTACK_ACCESS_KEY",
-
- "capabilities": {
- "project": "First Junit5 iOS Project",
- "build": "browserstack-build-1",
- "name": "first_test",
- "browserstack.debug": true,
- "app": "bs://"
- },
-
- "environments": [{
- "device": "iPhone 11 Pro",
- "os_version": "13"
- }]
-}
diff --git a/ios/junit5-examples/src/test/resources/com/browserstack/run_local_test/local.conf.json b/ios/junit5-examples/src/test/resources/com/browserstack/run_local_test/local.conf.json
deleted file mode 100644
index 411260d..0000000
--- a/ios/junit5-examples/src/test/resources/com/browserstack/run_local_test/local.conf.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "server": "hub-cloud.browserstack.com",
- "username": "BROWSERSTACK_USERNAME",
- "access_key": "BROWSERSTACK_ACCESS_KEY",
-
- "capabilities": {
- "project": "First Junit5 iOS Project",
- "build": "browserstack-build-1",
- "name": "local_test",
- "browserstack.debug": true,
- "browserstack.local": true,
- "app": "bs://"
- },
-
- "environments": [{
- "device": "iPhone 11 Pro",
- "os_version": "13"
- }]
-}
diff --git a/ios/junit5-examples/src/test/resources/com/browserstack/run_parallel_test/parallel.conf.json b/ios/junit5-examples/src/test/resources/com/browserstack/run_parallel_test/parallel.conf.json
deleted file mode 100644
index 388b5b0..0000000
--- a/ios/junit5-examples/src/test/resources/com/browserstack/run_parallel_test/parallel.conf.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "server": "hub-cloud.browserstack.com",
- "username": "BROWSERSTACK_USERNAME",
- "access_key": "fP6DdHuqEjCUEmnvJmz7",
-
- "capabilities": {
- "project": "First Junit5 iOS Project",
- "build": "browserstack-build-1",
- "name": "parallel_test",
- "browserstack.debug": true,
- "app": "bs://"
- },
-
- "environments": [{
- "device": "iPhone 11 Pro",
- "os_version": "13"
- }, {
- "device": "iPhone 11 Pro Max",
- "os_version": "13"
- }]
-}
diff --git a/junit-4/android/LocalSample.apk b/junit-4/android/LocalSample.apk
new file mode 100644
index 0000000..f31c574
Binary files /dev/null and b/junit-4/android/LocalSample.apk differ
diff --git a/junit-4/android/WikipediaSample.apk b/junit-4/android/WikipediaSample.apk
new file mode 100644
index 0000000..03d19e6
Binary files /dev/null and b/junit-4/android/WikipediaSample.apk differ
diff --git a/junit-4/android/browserstack.yml b/junit-4/android/browserstack.yml
new file mode 100644
index 0000000..6fea125
--- /dev/null
+++ b/junit-4/android/browserstack.yml
@@ -0,0 +1,76 @@
+# =============================
+# Set BrowserStack Credentials
+# =============================
+# Add your BrowserStack userName and acccessKey here or set BROWSERSTACK_USERNAME and
+# BROWSERSTACK_ACCESS_KEY as env variables
+userName: BROWSERSTACK_USERNAME
+accessKey: BROWSERSTACK_ACCESS_KEY
+
+# ======================
+# BrowserStack Reporting
+# ======================
+# The following capabilities are used to set up reporting on BrowserStack:
+# Set 'projectName' to the name of your project. Example, Marketing Website
+projectName: BrowserStack Samples
+# Set `buildName` as the name of the job / testsuite being run
+buildName: browserstack build
+# `buildIdentifier` is a unique id to differentiate every execution that gets appended to
+# buildName. Choose your buildIdentifier format from the available expressions:
+# ${BUILD_NUMBER} (Default): Generates an incremental counter with every execution
+# ${DATE_TIME}: Generates a Timestamp with every execution. Eg. 05-Nov-19:30
+# Read more about buildIdentifiers here -> https://www.browserstack.com/docs/automate/selenium/organize-tests
+buildIdentifier: '#${BUILD_NUMBER}' # Supports strings along with either/both ${expression}
+# Set `framework` of your test suite. Example, `testng`, `cucumber`, `cucumber-testng`
+# This property is needed to send test context to BrowserStack (test name, status)
+framework: junit4
+
+source: junit4:appium-sample-sdk:v1.1
+
+app: ./WikipediaSample.apk
+#app: ./LocalSample.apk #For running local tests
+
+# =======================================
+# Platforms (Browsers / Devices to test)
+# =======================================
+# Platforms object contains all the browser / device combinations you want to test on.
+# Entire list available here -> (https://www.browserstack.com/list-of-browsers-and-platforms/automate)
+platforms:
+ - deviceName: Samsung Galaxy S22 Ultra
+ platformVersion: 12.0
+ platformName: android
+ - deviceName: Google Pixel 8 Pro
+ platformVersion: 14.0
+ platformName: android
+ - deviceName: OnePlus 11R
+ platformVersion: 13.0
+ platformName: android
+
+# =======================
+# Parallels per Platform
+# =======================
+# The number of parallel threads to be used for each platform set.
+# BrowserStack's SDK runner will select the best strategy based on the configured value
+#
+# Example 1 - If you have configured 3 platforms and set `parallelsPerPlatform` as 2, a total of 6 (2 * 3) parallel threads will be used on BrowserStack
+#
+# Example 2 - If you have configured 1 platform and set `parallelsPerPlatform` as 5, a total of 5 (1 * 5) parallel threads will be used on BrowserStack
+parallelsPerPlatform: 1
+
+# ==========================================
+# BrowserStack Local
+# (For localhost, staging/private websites)
+# ==========================================
+# Set browserStackLocal to true if your website under test is not accessible publicly over the internet
+# Learn more about how BrowserStack Local works here -> https://www.browserstack.com/docs/automate/selenium/local-testing-introduction
+browserstackLocal: true # (Default false)
+#browserStackLocalOptions:
+#Options to be passed to BrowserStack local in-case of advanced configurations
+# localIdentifier: # (Default: null) Needed if you need to run multiple instances of local.
+# forceLocal: true # (Default: false) Set to true if you need to resolve all your traffic via BrowserStack Local tunnel.
+# Entire list of arguments available here -> https://www.browserstack.com/docs/automate/selenium/manage-incoming-connections
+
+# ===================
+# Debugging features
+# ===================
+debug: false # # Set to true if you need screenshots for every selenium command ran
+networkLogs: false # Set to true to enable HAR logs capturing
diff --git a/junit-4/android/build.gradle b/junit-4/android/build.gradle
new file mode 100644
index 0000000..67ee4cd
--- /dev/null
+++ b/junit-4/android/build.gradle
@@ -0,0 +1,50 @@
+plugins {
+ id 'java'
+ id 'com.browserstack.gradle-sdk' version "1.1.2"
+}
+
+repositories { mavenCentral() }
+
+dependencies {
+ testImplementation 'junit:junit:4.13.2'
+ implementation 'commons-io:commons-io:2.11.0'
+ implementation 'org.seleniumhq.selenium:selenium-java:4.4.0'
+ implementation 'io.appium:java-client:8.1.1'
+ implementation 'com.googlecode.json-simple:json-simple:1.1.1'
+ implementation 'com.browserstack:browserstack-java-sdk:latest.release'
+}
+
+group = 'com.browserstack'
+version = '1.0-SNAPSHOT'
+description = 'junit-browserstack'
+sourceCompatibility = '1.8'
+
+def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' }
+
+tasks.withType(JavaCompile) {
+ options.encoding = 'UTF-8'
+}
+
+tasks.withType(Test) {
+ systemProperties = System.properties
+ jvmArgs += "-javaagent:${browserstackSDKArtifact.file}"
+}
+
+task sampleTest(type: Test) {
+ dependsOn cleanTest
+ useJUnit()
+
+ include 'com/browserstack/FirstTest*'
+
+ jvmArgs "-javaagent:${configurations.testRuntimeClasspath.find { it.name.contains('browserstack-java-sdk') }}"
+}
+
+
+task sampleLocalTest(type: Test) {
+ dependsOn cleanTest
+ useJUnit()
+
+ include 'com/browserstack/LocalTest*'
+
+ jvmArgs "-javaagent:${configurations.testRuntimeClasspath.find { it.name.contains('browserstack-java-sdk') }}"
+}
diff --git a/junit-4/android/pom.xml b/junit-4/android/pom.xml
new file mode 100644
index 0000000..c34c411
--- /dev/null
+++ b/junit-4/android/pom.xml
@@ -0,0 +1,139 @@
+
+ 4.0.0
+
+ com.browserstack
+ junit4-browserstack
+ 1.0-SNAPSHOT
+ jar
+
+ junit-browserstack
+ https://www.github.com/browserstack/junit-appium-app-browserstack
+
+
+ UTF-8
+ 3.0.0-M5
+
+ FirstTest.java
+
+
+
+
+ junit
+ junit
+ 4.13.2
+
+
+ commons-io
+ commons-io
+ 2.11.0
+
+
+ org.seleniumhq.selenium
+ selenium-java
+ 4.4.0
+
+
+ io.appium
+ java-client
+ 8.1.1
+
+
+ com.googlecode.json-simple
+ json-simple
+ 1.1.1
+
+
+ com.browserstack
+ browserstack-java-sdk
+ LATEST
+ compile
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+ 3.3.0
+
+
+ getClasspathFilenames
+
+ properties
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${surefire.version}
+
+
+ org.apache.maven.surefire
+ surefire-junit47
+ ${surefire.version}
+
+
+
+
+ ${config.file}
+
+ -javaagent:${com.browserstack:browserstack-java-sdk:jar}
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.1
+
+ 1.8
+ 1.8
+
+
+
+
+
+
+
+ sample-test
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${surefire.version}
+
+
+ com/browserstack/FirstTest.java
+
+ -javaagent:${com.browserstack:browserstack-java-sdk:jar}
+
+
+
+
+
+
+
+ sample-local-test
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${surefire.version}
+
+
+ com/browserstack/LocalTest.java
+
+ -javaagent:${com.browserstack:browserstack-java-sdk:jar}
+
+
+
+
+
+
+
+
diff --git a/junit-4/android/settings.gradle b/junit-4/android/settings.gradle
new file mode 100644
index 0000000..3e5b662
--- /dev/null
+++ b/junit-4/android/settings.gradle
@@ -0,0 +1,15 @@
+pluginManagement {
+ repositories {
+ mavenCentral()
+ mavenLocal()
+ gradlePluginPortal()
+ }
+
+ resolutionStrategy {
+ eachPlugin {
+ if (requested.id.id == "com.browserstack.gradle-sdk") {
+ useModule("com.browserstack:gradle-sdk:1.1.2")
+ }
+ }
+ }
+}
diff --git a/junit-4/android/src/test/java/com/browserstack/BrowserStackJUnitTest.java b/junit-4/android/src/test/java/com/browserstack/BrowserStackJUnitTest.java
new file mode 100644
index 0000000..c5b5d5b
--- /dev/null
+++ b/junit-4/android/src/test/java/com/browserstack/BrowserStackJUnitTest.java
@@ -0,0 +1,63 @@
+package com.browserstack;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.nio.file.Files;
+import java.util.HashMap;
+import java.util.Map;
+
+import io.appium.java_client.android.AndroidDriver;
+import io.appium.java_client.android.options.UiAutomator2Options;
+import org.junit.After;
+import org.junit.Before;
+import org.yaml.snakeyaml.Yaml;
+
+public class BrowserStackJUnitTest {
+ public AndroidDriver driver;
+ public String userName;
+ public String accessKey;
+ public UiAutomator2Options options;
+ public static Map browserStackYamlMap;
+ public static final String USER_DIR = "user.dir";
+
+ public BrowserStackJUnitTest() {
+ File file = new File(getUserDir() + "/browserstack.yml");
+ this.browserStackYamlMap = convertYamlFileToMap(file, new HashMap<>());
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ options = new UiAutomator2Options();
+ userName = System.getenv("BROWSERSTACK_USERNAME") != null ? System.getenv("BROWSERSTACK_USERNAME") : (String) browserStackYamlMap.get("userName");
+ accessKey = System.getenv("BROWSERSTACK_ACCESS_KEY") != null ? System.getenv("BROWSERSTACK_ACCESS_KEY") : (String) browserStackYamlMap.get("accessKey");
+ options.setCapability("appium:app", "bs://sample.app");
+ options.setCapability("appium:deviceName", "Samsung Galaxy S22 Ultra");
+ options.setCapability("appium:platformVersion", "12.0");
+
+ driver = new AndroidDriver(new URL(String.format("https://%s:%s@hub.browserstack.com/wd/hub", userName , accessKey)), options);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ // Invoke driver.quit() to indicate that the test is completed.
+ // Otherwise, it will appear as timed out on BrowserStack.
+ driver.quit();
+ }
+
+ private String getUserDir() {
+ return System.getProperty(USER_DIR);
+ }
+
+ private Map convertYamlFileToMap(File yamlFile, Map map) {
+ try {
+ InputStream inputStream = Files.newInputStream(yamlFile.toPath());
+ Yaml yaml = new Yaml();
+ Map config = yaml.load(inputStream);
+ map.putAll(config);
+ } catch (Exception e) {
+ throw new RuntimeException(String.format("Malformed browserstack.yml file - %s.", e));
+ }
+ return map;
+ }
+}
diff --git a/junit-4/android/src/test/java/com/browserstack/FirstTest.java b/junit-4/android/src/test/java/com/browserstack/FirstTest.java
new file mode 100644
index 0000000..715445f
--- /dev/null
+++ b/junit-4/android/src/test/java/com/browserstack/FirstTest.java
@@ -0,0 +1,30 @@
+package com.browserstack;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import java.util.List;
+import java.time.Duration;
+
+import io.appium.java_client.AppiumBy;
+
+import org.openqa.selenium.support.ui.WebDriverWait;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.WebElement;
+
+public class FirstTest extends BrowserStackJUnitTest {
+
+ @Test
+ public void test() throws Exception {
+ WebElement searchElement = (WebElement) new WebDriverWait(driver, Duration.ofSeconds(30)).until(
+ ExpectedConditions.elementToBeClickable(AppiumBy.accessibilityId("Search Wikipedia")));
+ searchElement.click();
+ WebElement insertTextElement = (WebElement) new WebDriverWait(driver, Duration.ofSeconds(30)).until(
+ ExpectedConditions.elementToBeClickable(AppiumBy.id("org.wikipedia.alpha:id/search_src_text")));
+ insertTextElement.sendKeys("BrowserStack");
+ Thread.sleep(5000);
+
+ List allProductsName = driver.findElements(AppiumBy.className("android.widget.TextView"));
+ assertTrue(allProductsName.size() > 0);
+ }
+}
diff --git a/android/junit4-examples/src/test/java/com/browserstack/run_local_test/LocalTest.java b/junit-4/android/src/test/java/com/browserstack/LocalTest.java
similarity index 66%
rename from android/junit4-examples/src/test/java/com/browserstack/run_local_test/LocalTest.java
rename to junit-4/android/src/test/java/com/browserstack/LocalTest.java
index a45cc9d..cf99eeb 100644
--- a/android/junit4-examples/src/test/java/com/browserstack/run_local_test/LocalTest.java
+++ b/junit-4/android/src/test/java/com/browserstack/LocalTest.java
@@ -1,15 +1,16 @@
-package com.browserstack.run_local_test;
+package com.browserstack;
import static org.junit.Assert.*;
import java.io.File;
+import java.time.Duration;
import org.junit.Test;
import java.util.List;
import org.apache.commons.io.FileUtils;
-import io.appium.java_client.MobileBy;
-import io.appium.java_client.android.AndroidElement;
+import io.appium.java_client.AppiumBy;
+import org.openqa.selenium.WebElement;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.support.ui.WebDriverWait;
@@ -19,16 +20,16 @@ public class LocalTest extends BrowserStackJUnitTest {
@Test
public void test() throws Exception {
- AndroidElement searchElement = (AndroidElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.id("com.example.android.basicnetworking:id/test_action")));
+ WebElement searchElement = (WebElement) new WebDriverWait(driver, Duration.ofSeconds(30)).until(
+ ExpectedConditions.elementToBeClickable(AppiumBy.id("com.example.android.basicnetworking:id/test_action")));
searchElement.click();
- AndroidElement insertTextElement = (AndroidElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.className("android.widget.TextView")));
+ WebElement insertTextElement = (WebElement) new WebDriverWait(driver, Duration.ofSeconds(30)).until(
+ ExpectedConditions.elementToBeClickable(AppiumBy.className("android.widget.TextView")));
- AndroidElement testElement = null;
- List allTextViewElements = driver.findElementsByClassName("android.widget.TextView");
+ WebElement testElement = null;
+ List allTextViewElements = driver.findElements(AppiumBy.className("android.widget.TextView"));
Thread.sleep(10);
- for(AndroidElement textElement : allTextViewElements) {
+ for(WebElement textElement : allTextViewElements) {
if(textElement.getText().contains("The active connection is")) {
testElement = textElement;
}
diff --git a/junit-4/ios/BStackSampleApp.ipa b/junit-4/ios/BStackSampleApp.ipa
new file mode 100644
index 0000000..c1891b8
Binary files /dev/null and b/junit-4/ios/BStackSampleApp.ipa differ
diff --git a/junit-4/ios/LocalSample.ipa b/junit-4/ios/LocalSample.ipa
new file mode 100644
index 0000000..a937349
Binary files /dev/null and b/junit-4/ios/LocalSample.ipa differ
diff --git a/junit-4/ios/browserstack.yml b/junit-4/ios/browserstack.yml
new file mode 100644
index 0000000..54b6d10
--- /dev/null
+++ b/junit-4/ios/browserstack.yml
@@ -0,0 +1,77 @@
+# =============================
+# Set BrowserStack Credentials
+# =============================
+# Add your BrowserStack userName and accessKey here or set BROWSERSTACK_USERNAME and
+# BROWSERSTACK_ACCESS_KEY as env variables
+userName: BROWSERSTACK_USERNAME
+accessKey: BROWSERSTACK_ACCESS_KEY
+
+# ======================
+# BrowserStack Reporting
+# ======================
+# The following capabilities are used to set up reporting on BrowserStack:
+# Set 'projectName' to the name of your project. Example, Marketing Website
+projectName: BrowserStack Samples
+# Set `buildName` as the name of the job / testsuite being run
+buildName: browserstack build
+# `buildIdentifier` is a unique id to differentiate every execution that gets appended to
+# buildName. Choose your buildIdentifier format from the available expressions:
+# ${BUILD_NUMBER} (Default): Generates an incremental counter with every execution
+# ${DATE_TIME}: Generates a Timestamp with every execution. Eg. 05-Nov-19:30
+# Read more about buildIdentifiers here -> https://www.browserstack.com/docs/automate/selenium/organize-tests
+buildIdentifier: '#${BUILD_NUMBER}' # Supports strings along with either/both ${expression}
+# Set `framework` of your test suite. Example, `testng`, `cucumber`, `cucumber-testng`
+# This property is needed to send test context to BrowserStack (test name, status)
+framework: junit4
+
+source: junit4:appium-sample-sdk:v1.1
+
+app: ./BStackSampleApp.ipa
+#app: ./LocalSample.ipa #For running local tests
+
+# =======================================
+# Platforms (Browsers / Devices to test)
+# =======================================
+# Platforms object contains all the browser / device combinations you want to test on.
+# Entire list available here -> (https://www.browserstack.com/list-of-browsers-and-platforms/automate)
+
+platforms:
+ - deviceName: iPhone 14 Pro Max
+ platformVersion: 16
+ platformName: ios
+ - deviceName: iPhone 13
+ platformVersion: 15
+ platformName: ios
+ - deviceName: iPhone 15
+ platformVersion: 17
+ platformName: ios
+
+# =======================
+# Parallels per Platform
+# =======================
+# The number of parallel threads to be used for each platform set.
+# BrowserStack's SDK runner will select the best strategy based on the configured value
+#
+# Example 1 - If you have configured 3 platforms and set `parallelsPerPlatform` as 2, a total of 6 (2 * 3) parallel threads will be used on BrowserStack
+#
+# Example 2 - If you have configured 1 platform and set `parallelsPerPlatform` as 5, a total of 5 (1 * 5) parallel threads will be used on BrowserStack
+parallelsPerPlatform: 1
+
+# ==========================================
+# BrowserStack Local
+# (For localhost, staging/private websites)
+# ==========================================
+# Set browserStackLocal to true if your website under test is not accessible publicly over the internet
+# Learn more about how BrowserStack Local works here -> https://www.browserstack.com/docs/automate/selenium/local-testing-introduction
+browserstackLocal: true # (Default false)
+#browserStackLocalOptions:
+#Options to be passed to BrowserStack local in-case of advanced configurations
+# localIdentifier: # (Default: null) Needed if you need to run multiple instances of local.
+# forceLocal: true # (Default: false) Set to true if you need to resolve all your traffic via BrowserStack Local tunnel.
+# Entire list of arguments available here -> https://www.browserstack.com/docs/automate/selenium/manage-incoming-connections
+
+# ===================
+# Debugging features
+# ===================
+debug: false # # Set to true if you need screenshots for every selenium command ran
+networkLogs: false # Set to true to enable HAR logs capturing
diff --git a/junit-4/ios/build.gradle b/junit-4/ios/build.gradle
new file mode 100644
index 0000000..67ee4cd
--- /dev/null
+++ b/junit-4/ios/build.gradle
@@ -0,0 +1,50 @@
+plugins {
+ id 'java'
+ id 'com.browserstack.gradle-sdk' version "1.1.2"
+}
+
+repositories { mavenCentral() }
+
+dependencies {
+ testImplementation 'junit:junit:4.13.2'
+ implementation 'commons-io:commons-io:2.11.0'
+ implementation 'org.seleniumhq.selenium:selenium-java:4.4.0'
+ implementation 'io.appium:java-client:8.1.1'
+ implementation 'com.googlecode.json-simple:json-simple:1.1.1'
+ implementation 'com.browserstack:browserstack-java-sdk:latest.release'
+}
+
+group = 'com.browserstack'
+version = '1.0-SNAPSHOT'
+description = 'junit-browserstack'
+sourceCompatibility = '1.8'
+
+def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' }
+
+tasks.withType(JavaCompile) {
+ options.encoding = 'UTF-8'
+}
+
+tasks.withType(Test) {
+ systemProperties = System.properties
+ jvmArgs += "-javaagent:${browserstackSDKArtifact.file}"
+}
+
+task sampleTest(type: Test) {
+ dependsOn cleanTest
+ useJUnit()
+
+ include 'com/browserstack/FirstTest*'
+
+ jvmArgs "-javaagent:${configurations.testRuntimeClasspath.find { it.name.contains('browserstack-java-sdk') }}"
+}
+
+
+task sampleLocalTest(type: Test) {
+ dependsOn cleanTest
+ useJUnit()
+
+ include 'com/browserstack/LocalTest*'
+
+ jvmArgs "-javaagent:${configurations.testRuntimeClasspath.find { it.name.contains('browserstack-java-sdk') }}"
+}
diff --git a/junit-4/ios/pom.xml b/junit-4/ios/pom.xml
new file mode 100644
index 0000000..3d77ee8
--- /dev/null
+++ b/junit-4/ios/pom.xml
@@ -0,0 +1,139 @@
+
+ 4.0.0
+
+ com.browserstack
+ junit4-browserstack
+ 1.0-SNAPSHOT
+ jar
+
+ junit-browserstack
+ https://www.github.com/browserstack/junit-appium-app-browserstack
+
+
+ UTF-8
+ 3.0.0-M5
+
+ default
+
+
+
+
+ junit
+ junit
+ 4.13.2
+
+
+ commons-io
+ commons-io
+ 2.11.0
+
+
+ org.seleniumhq.selenium
+ selenium-java
+ 4.4.0
+
+
+ io.appium
+ java-client
+ 8.1.1
+
+
+ com.googlecode.json-simple
+ json-simple
+ 1.1.1
+
+
+ com.browserstack
+ browserstack-java-sdk
+ LATEST
+ compile
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+ 3.3.0
+
+
+ getClasspathFilenames
+
+ properties
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${surefire.version}
+
+
+ org.apache.maven.surefire
+ surefire-junit47
+ ${surefire.version}
+
+
+
+
+ com/browserstack/FirstTest.java
+
+ -javaagent:${com.browserstack:browserstack-java-sdk:jar}
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.1
+
+ 1.8
+ 1.8
+
+
+
+
+
+
+
+ sample-test
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${surefire.version}
+
+
+ com/browserstack/FirstTest.java
+
+ -javaagent:${com.browserstack:browserstack-java-sdk:jar}
+
+
+
+
+
+
+
+ sample-local-test
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${surefire.version}
+
+
+ com/browserstack/LocalTest.java
+
+ -javaagent:${com.browserstack:browserstack-java-sdk:jar}
+
+
+
+
+
+
+
+
diff --git a/junit-4/ios/settings.gradle b/junit-4/ios/settings.gradle
new file mode 100644
index 0000000..3e5b662
--- /dev/null
+++ b/junit-4/ios/settings.gradle
@@ -0,0 +1,15 @@
+pluginManagement {
+ repositories {
+ mavenCentral()
+ mavenLocal()
+ gradlePluginPortal()
+ }
+
+ resolutionStrategy {
+ eachPlugin {
+ if (requested.id.id == "com.browserstack.gradle-sdk") {
+ useModule("com.browserstack:gradle-sdk:1.1.2")
+ }
+ }
+ }
+}
diff --git a/junit-4/ios/src/test/java/com/browserstack/BrowserStackJUnitTest.java b/junit-4/ios/src/test/java/com/browserstack/BrowserStackJUnitTest.java
new file mode 100644
index 0000000..ea7f655
--- /dev/null
+++ b/junit-4/ios/src/test/java/com/browserstack/BrowserStackJUnitTest.java
@@ -0,0 +1,63 @@
+package com.browserstack;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.nio.file.Files;
+import java.util.HashMap;
+import java.util.Map;
+
+import io.appium.java_client.ios.IOSDriver;
+import io.appium.java_client.ios.options.XCUITestOptions;
+import org.junit.After;
+import org.junit.Before;
+import org.yaml.snakeyaml.Yaml;
+
+public class BrowserStackJUnitTest {
+ public IOSDriver driver;
+ public String userName;
+ public String accessKey;
+ public XCUITestOptions options;
+ public static Map browserStackYamlMap;
+ public static final String USER_DIR = "user.dir";
+
+ public BrowserStackJUnitTest() {
+ File file = new File(getUserDir() + "/browserstack.yml");
+ this.browserStackYamlMap = convertYamlFileToMap(file, new HashMap<>());
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ options = new XCUITestOptions();
+ userName = System.getenv("BROWSERSTACK_USERNAME") != null ? System.getenv("BROWSERSTACK_USERNAME") : (String) browserStackYamlMap.get("userName");
+ accessKey = System.getenv("BROWSERSTACK_ACCESS_KEY") != null ? System.getenv("BROWSERSTACK_ACCESS_KEY") : (String) browserStackYamlMap.get("accessKey");
+ options.setCapability("appium:app", "bs://sample.app");
+ options.setCapability("appium:deviceName", "iPhone 14 Pro");
+ options.setCapability("appium:platformVersion", "16");
+
+ driver = new IOSDriver(new URL(String.format("https://%s:%s@hub.browserstack.com/wd/hub", userName , accessKey)), options);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ // Invoke driver.quit() to indicate that the test is completed.
+ // Otherwise, it will appear as timed out on BrowserStack.
+ driver.quit();
+ }
+
+ private String getUserDir() {
+ return System.getProperty(USER_DIR);
+ }
+
+ private Map convertYamlFileToMap(File yamlFile, Map map) {
+ try {
+ InputStream inputStream = Files.newInputStream(yamlFile.toPath());
+ Yaml yaml = new Yaml();
+ Map config = yaml.load(inputStream);
+ map.putAll(config);
+ } catch (Exception e) {
+ throw new RuntimeException(String.format("Malformed browserstack.yml file - %s.", e));
+ }
+ return map;
+ }
+}
diff --git a/junit-4/ios/src/test/java/com/browserstack/FirstTest.java b/junit-4/ios/src/test/java/com/browserstack/FirstTest.java
new file mode 100644
index 0000000..d95ccc8
--- /dev/null
+++ b/junit-4/ios/src/test/java/com/browserstack/FirstTest.java
@@ -0,0 +1,33 @@
+package com.browserstack;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import io.appium.java_client.AppiumBy;
+
+import org.openqa.selenium.support.ui.WebDriverWait;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.WebElement;
+
+import java.time.Duration;
+
+public class FirstTest extends BrowserStackJUnitTest {
+
+ @Test
+ public void test() throws Exception {
+ WebElement textButton = (WebElement) new WebDriverWait(driver, Duration.ofSeconds(30)).until(
+ ExpectedConditions.elementToBeClickable(AppiumBy.accessibilityId("Text Button")));
+ textButton.click();
+ WebElement textInput = (WebElement) new WebDriverWait(driver, Duration.ofSeconds(30)).until(
+ ExpectedConditions.elementToBeClickable(AppiumBy.accessibilityId("Text Input")));
+ textInput.sendKeys("hello@browserstack.com" + "\n");
+
+ Thread.sleep(5000);
+
+ WebElement textOutput = (WebElement) new WebDriverWait(driver, Duration.ofSeconds(30)).until(
+ ExpectedConditions.elementToBeClickable(AppiumBy.accessibilityId("Text Output")));
+
+ assertEquals(textOutput.getText(),"hello@browserstack.com");
+ }
+}
diff --git a/ios/junit4-examples/src/test/java/com/browserstack/run_local_test/LocalTest.java b/junit-4/ios/src/test/java/com/browserstack/LocalTest.java
similarity index 72%
rename from ios/junit4-examples/src/test/java/com/browserstack/run_local_test/LocalTest.java
rename to junit-4/ios/src/test/java/com/browserstack/LocalTest.java
index 9f87be1..d48e3d2 100644
--- a/ios/junit4-examples/src/test/java/com/browserstack/run_local_test/LocalTest.java
+++ b/junit-4/ios/src/test/java/com/browserstack/LocalTest.java
@@ -1,14 +1,13 @@
-package com.browserstack.run_local_test;
+package com.browserstack;
import static org.junit.Assert.*;
import java.io.File;
-import io.appium.java_client.ios.IOSElement;
import org.junit.Test;
import org.apache.commons.io.FileUtils;
-import io.appium.java_client.MobileBy;
+import io.appium.java_client.AppiumBy;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
@@ -16,24 +15,27 @@
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.WebElement;
+
+import java.time.Duration;
public class LocalTest extends BrowserStackJUnitTest {
@Test
public void test() throws Exception {
- IOSElement testButton = (IOSElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("TestBrowserStackLocal")));
+ WebElement testButton = (WebElement) new WebDriverWait(driver, Duration.ofSeconds(30)).until(
+ ExpectedConditions.elementToBeClickable(AppiumBy.accessibilityId("TestBrowserStackLocal")));
testButton.click();
- WebDriverWait wait = new WebDriverWait(driver, 30);
+ WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(30));
wait.until(new ExpectedCondition() {
@Override
public Boolean apply(WebDriver d) {
- String result = d.findElement(MobileBy.AccessibilityId("ResultBrowserStackLocal")).getAttribute("value");
+ String result = d.findElement(AppiumBy.accessibilityId("ResultBrowserStackLocal")).getAttribute("value");
return result != null && result.length() > 0;
}
});
- IOSElement resultElement = (IOSElement) driver.findElement(MobileBy.AccessibilityId("ResultBrowserStackLocal"));
+ WebElement resultElement = (WebElement) driver.findElement(AppiumBy.accessibilityId("ResultBrowserStackLocal"));
String resultString = resultElement.getText().toLowerCase();
System.out.println(resultString);
diff --git a/junit-5/android/LocalSample.apk b/junit-5/android/LocalSample.apk
new file mode 100644
index 0000000..f31c574
Binary files /dev/null and b/junit-5/android/LocalSample.apk differ
diff --git a/junit-5/android/WikipediaSample.apk b/junit-5/android/WikipediaSample.apk
new file mode 100644
index 0000000..03d19e6
Binary files /dev/null and b/junit-5/android/WikipediaSample.apk differ
diff --git a/junit-5/android/browserstack.yml b/junit-5/android/browserstack.yml
new file mode 100644
index 0000000..96eb1f5
--- /dev/null
+++ b/junit-5/android/browserstack.yml
@@ -0,0 +1,77 @@
+# =============================
+# Set BrowserStack Credentials
+# =============================
+# Add your BrowserStack userName and acccessKey here or set BROWSERSTACK_USERNAME and
+# BROWSERSTACK_ACCESS_KEY as env variables
+userName: BROWSERSTACK_USERNAME
+accessKey: BROWSERSTACK_ACCESS_KEY
+
+# ======================
+# BrowserStack Reporting
+# ======================
+# The following capabilities are used to set up reporting on BrowserStack:
+# Set 'projectName' to the name of your project. Example, Marketing Website
+projectName: BrowserStack Samples
+# Set `buildName` as the name of the job / testsuite being run
+buildName: browserstack build
+# `buildIdentifier` is a unique id to differentiate every execution that gets appended to
+# buildName. Choose your buildIdentifier format from the available expressions:
+# ${BUILD_NUMBER} (Default): Generates an incremental counter with every execution
+# ${DATE_TIME}: Generates a Timestamp with every execution. Eg. 05-Nov-19:30
+# Read more about buildIdentifiers here -> https://www.browserstack.com/docs/automate/selenium/organize-tests
+buildIdentifier: '#${BUILD_NUMBER}' # Supports strings along with either/both ${expression}
+# Set `framework` of your test suite. Example, `testng`, `cucumber`, `cucumber-testng`
+# This property is needed to send test context to BrowserStack (test name, status)
+framework: junit5
+
+source: junit5:appium-sample-sdk:v1.1
+
+app: ./WikipediaSample.apk
+#app: ./LocalSample.apk #For running local tests
+
+# =======================================
+# Platforms (Browsers / Devices to test)
+# =======================================
+# Platforms object contains all the browser / device combinations you want to test on.
+# Entire list available here -> (https://www.browserstack.com/list-of-browsers-and-platforms/automate)
+
+platforms:
+ - deviceName: Samsung Galaxy S22 Ultra
+ platformVersion: 12.0
+ platformName: android
+ - deviceName: Google Pixel 8 Pro
+ platformVersion: 14.0
+ platformName: android
+ - deviceName: OnePlus 11R
+ platformVersion: 13.0
+ platformName: android
+
+# =======================
+# Parallels per Platform
+# =======================
+# The number of parallel threads to be used for each platform set.
+# BrowserStack's SDK runner will select the best strategy based on the configured value
+#
+# Example 1 - If you have configured 3 platforms and set `parallelsPerPlatform` as 2, a total of 6 (2 * 3) parallel threads will be used on BrowserStack
+#
+# Example 2 - If you have configured 1 platform and set `parallelsPerPlatform` as 5, a total of 5 (1 * 5) parallel threads will be used on BrowserStack
+parallelsPerPlatform: 1
+
+# ==========================================
+# BrowserStack Local
+# (For localhost, staging/private websites)
+# ==========================================
+# Set browserStackLocal to true if your website under test is not accessible publicly over the internet
+# Learn more about how BrowserStack Local works here -> https://www.browserstack.com/docs/automate/selenium/local-testing-introduction
+browserstackLocal: true # (Default false)
+#browserStackLocalOptions:
+#Options to be passed to BrowserStack local in-case of advanced configurations
+# localIdentifier: # (Default: null) Needed if you need to run multiple instances of local.
+# forceLocal: true # (Default: false) Set to true if you need to resolve all your traffic via BrowserStack Local tunnel.
+# Entire list of arguments available here -> https://www.browserstack.com/docs/automate/selenium/manage-incoming-connections
+
+# ===================
+# Debugging features
+# ===================
+debug: false # # Set to true if you need screenshots for every selenium command ran
+networkLogs: false # Set to true to enable HAR logs capturing
diff --git a/junit-5/android/build.gradle b/junit-5/android/build.gradle
new file mode 100644
index 0000000..1757ca2
--- /dev/null
+++ b/junit-5/android/build.gradle
@@ -0,0 +1,51 @@
+plugins {
+ id 'java'
+ id 'com.browserstack.gradle-sdk' version "1.1.2"
+}
+
+repositories { mavenCentral() }
+
+dependencies {
+ testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
+ testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
+ implementation 'commons-io:commons-io:2.11.0'
+ implementation 'org.seleniumhq.selenium:selenium-java:4.4.0'
+ implementation 'io.appium:java-client:8.1.1'
+ implementation 'com.googlecode.json-simple:json-simple:1.1.1'
+ implementation 'com.browserstack:browserstack-java-sdk:latest.release'
+}
+
+group = 'com.browserstack'
+version = '1.0-SNAPSHOT'
+description = 'junit-browserstack'
+sourceCompatibility = '1.8'
+
+def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' }
+
+tasks.withType(JavaCompile) {
+ options.encoding = 'UTF-8'
+}
+
+tasks.withType(Test) {
+ systemProperties = System.properties
+ jvmArgs += "-javaagent:${browserstackSDKArtifact.file}"
+}
+
+task sampleTest(type: Test) {
+ dependsOn cleanTest
+ useJUnitPlatform()
+
+ include 'com/browserstack/FirstTest*'
+
+ jvmArgs "-javaagent:${configurations.testRuntimeClasspath.find { it.name.contains('browserstack-java-sdk') }}"
+}
+
+
+task sampleLocalTest(type: Test) {
+ dependsOn cleanTest
+ useJUnitPlatform()
+
+ include 'com/browserstack/LocalTest*'
+
+ jvmArgs "-javaagent:${configurations.testRuntimeClasspath.find { it.name.contains('browserstack-java-sdk') }}"
+}
diff --git a/android/junit5-examples/pom.xml b/junit-5/android/pom.xml
similarity index 64%
rename from android/junit5-examples/pom.xml
rename to junit-5/android/pom.xml
index 8041b05..5daf299 100644
--- a/android/junit5-examples/pom.xml
+++ b/junit-5/android/pom.xml
@@ -12,64 +12,76 @@
UTF-8
- 2.19.1
-
-
- default
+ 3.0.0-M5
+ com/browserstack/FirstTest.java
org.junit.jupiter
- junit-jupiter-engine
- 5.5.2
+ junit-jupiter-api
+ 5.9.0
test
org.junit.jupiter
- junit-jupiter-params
- 5.5.2
+ junit-jupiter-engine
+ 5.9.0
test
commons-io
commons-io
- 1.3.2
+ 2.11.0
org.seleniumhq.selenium
selenium-java
- 3.141.59
+ 4.4.0
io.appium
java-client
- 7.0.0
-
-
- com.browserstack
- browserstack-local-java
- 1.0.3
+ 8.1.1
com.googlecode.json-simple
json-simple
1.1.1
+
+ com.browserstack
+ browserstack-java-sdk
+ LATEST
+ compile
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ getClasspathFilenames
+
+ properties
+
+
+
+
org.apache.maven.plugins
maven-surefire-plugin
- 2.22.2
+ ${surefire.version}
-
-
- junit.jupiter.execution.parallel.enabled=true
-
-
+
+ ${config.file}
+
+
+ -javaagent:${com.browserstack:browserstack-java-sdk:jar}
+
@@ -86,24 +98,7 @@
- first
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- FirstTest.java
-
-
-
-
-
-
-
-
- parallel
+ sample-test
@@ -111,8 +106,11 @@
maven-surefire-plugin
- ParallelTest.java
+ com/browserstack/FirstTest.java
+
+ -javaagent:${com.browserstack:browserstack-java-sdk:jar}
+
@@ -120,7 +118,7 @@
- local
+ sample-local-test
@@ -128,8 +126,11 @@
maven-surefire-plugin
- LocalTest.java
+ com/browserstack/LocalTest.java
+
+ -javaagent:${com.browserstack:browserstack-java-sdk:jar}
+
diff --git a/junit-5/android/settings.gradle b/junit-5/android/settings.gradle
new file mode 100644
index 0000000..3e5b662
--- /dev/null
+++ b/junit-5/android/settings.gradle
@@ -0,0 +1,15 @@
+pluginManagement {
+ repositories {
+ mavenCentral()
+ mavenLocal()
+ gradlePluginPortal()
+ }
+
+ resolutionStrategy {
+ eachPlugin {
+ if (requested.id.id == "com.browserstack.gradle-sdk") {
+ useModule("com.browserstack:gradle-sdk:1.1.2")
+ }
+ }
+ }
+}
diff --git a/junit-5/android/src/test/java/com/browserstack/BrowserStackJUnitTest.java b/junit-5/android/src/test/java/com/browserstack/BrowserStackJUnitTest.java
new file mode 100644
index 0000000..2b6040c
--- /dev/null
+++ b/junit-5/android/src/test/java/com/browserstack/BrowserStackJUnitTest.java
@@ -0,0 +1,63 @@
+package com.browserstack;
+
+import io.appium.java_client.android.AndroidDriver;
+import io.appium.java_client.android.options.UiAutomator2Options;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.nio.file.Files;
+import java.util.*;
+
+public class BrowserStackJUnitTest {
+
+ public AndroidDriver driver;
+ public String userName;
+ public String accessKey;
+ public UiAutomator2Options options;
+ public static Map browserStackYamlMap;
+ public static final String USER_DIR = "user.dir";
+
+ public BrowserStackJUnitTest() {
+ File file = new File(getUserDir() + "/browserstack.yml");
+ this.browserStackYamlMap = convertYamlFileToMap(file, new HashMap<>());
+ }
+
+ @BeforeEach
+ public void setup() throws Exception {
+ options = new UiAutomator2Options();
+ userName = System.getenv("BROWSERSTACK_USERNAME") != null ? System.getenv("BROWSERSTACK_USERNAME") : (String) browserStackYamlMap.get("userName");
+ accessKey = System.getenv("BROWSERSTACK_ACCESS_KEY") != null ? System.getenv("BROWSERSTACK_ACCESS_KEY") : (String) browserStackYamlMap.get("accessKey");
+ options.setCapability("appium:app", "bs://sample.app");
+ options.setCapability("appium:deviceName", "Samsung Galaxy S22 Ultra");
+ options.setCapability("appium:platformVersion", "12.0");
+
+ driver = new AndroidDriver(new URL(String.format("https://%s:%s@hub.browserstack.com/wd/hub", userName , accessKey)), options);
+ }
+
+ @AfterEach
+ public void tearDown() throws Exception {
+ // Invoke driver.quit() to indicate that the test is completed.
+ // Otherwise, it will appear as timed out on BrowserStack.
+ driver.quit();
+ }
+
+ private String getUserDir() {
+ return System.getProperty(USER_DIR);
+ }
+
+ private Map convertYamlFileToMap(File yamlFile, Map map) {
+ try {
+ InputStream inputStream = Files.newInputStream(yamlFile.toPath());
+ Yaml yaml = new Yaml();
+ Map config = yaml.load(inputStream);
+ map.putAll(config);
+ } catch (Exception e) {
+ throw new RuntimeException(String.format("Malformed browserstack.yml file - %s.", e));
+ }
+ return map;
+ }
+}
diff --git a/junit-5/android/src/test/java/com/browserstack/FirstTest.java b/junit-5/android/src/test/java/com/browserstack/FirstTest.java
new file mode 100644
index 0000000..bd30c1d
--- /dev/null
+++ b/junit-5/android/src/test/java/com/browserstack/FirstTest.java
@@ -0,0 +1,33 @@
+package com.browserstack;
+
+import io.appium.java_client.AppiumBy;
+import org.junit.jupiter.api.Test;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
+import org.openqa.selenium.WebElement;
+
+import java.io.IOException;
+import java.util.List;
+import java.time.Duration;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class FirstTest extends BrowserStackJUnitTest{
+
+ @Test
+ void test() throws IOException, InterruptedException {
+
+ WebElement searchElement = (WebElement) new WebDriverWait(driver, Duration.ofSeconds(30)).until(
+ ExpectedConditions.elementToBeClickable(AppiumBy.accessibilityId("Search Wikipedia")));
+ searchElement.click();
+
+ WebElement insertTextElement = (WebElement) new WebDriverWait(driver, Duration.ofSeconds(30)).until(
+ ExpectedConditions.elementToBeClickable(AppiumBy.id("org.wikipedia.alpha:id/search_src_text")));
+ insertTextElement.sendKeys("BrowserStack");
+
+ Thread.sleep(5000);
+
+ List allProductsName = driver.findElements(AppiumBy.className("android.widget.TextView"));
+ assertTrue(allProductsName.size() > 0);
+ }
+}
diff --git a/android/junit5-examples/src/test/java/com/browserstack/run_local_test/LocalTest.java b/junit-5/android/src/test/java/com/browserstack/LocalTest.java
similarity index 59%
rename from android/junit5-examples/src/test/java/com/browserstack/run_local_test/LocalTest.java
rename to junit-5/android/src/test/java/com/browserstack/LocalTest.java
index e662d23..ee72dc0 100644
--- a/android/junit5-examples/src/test/java/com/browserstack/run_local_test/LocalTest.java
+++ b/junit-5/android/src/test/java/com/browserstack/LocalTest.java
@@ -1,39 +1,36 @@
-package com.browserstack.run_local_test;
+package com.browserstack;
+
+import io.appium.java_client.AppiumBy;
-import io.appium.java_client.MobileBy;
-import io.appium.java_client.android.AndroidElement;
import org.apache.commons.io.FileUtils;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.MethodSource;
+import org.junit.jupiter.api.Test;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
+import org.openqa.selenium.WebElement;
import java.io.File;
import java.io.IOException;
import java.util.List;
+import java.time.Duration;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class LocalTest extends BrowserStackJUnitTest{
- @ParameterizedTest
- @MethodSource("devices")
- void test(int taskId) throws IOException, InterruptedException {
-
- createConnection(taskId);
-
- AndroidElement searchElement = (AndroidElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.id("com.example.android.basicnetworking:id/test_action")));
+ @Test
+ void test() throws IOException, InterruptedException {
+ WebElement searchElement = (WebElement) new WebDriverWait(driver, Duration.ofSeconds(30)).until(
+ ExpectedConditions.elementToBeClickable(AppiumBy.id("com.example.android.basicnetworking:id/test_action")));
searchElement.click();
- AndroidElement insertTextElement = (AndroidElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.className("android.widget.TextView")));
+ WebElement insertTextElement = (WebElement) new WebDriverWait(driver, Duration.ofSeconds(30)).until(
+ ExpectedConditions.elementToBeClickable(AppiumBy.className("android.widget.TextView")));
- AndroidElement testElement = null;
- List allTextViewElements = driver.findElementsByClassName("android.widget.TextView");
+ WebElement testElement = null;
+ List allTextViewElements = driver.findElements(AppiumBy.className("android.widget.TextView"));
Thread.sleep(10);
- for(AndroidElement textElement : allTextViewElements) {
+ for(WebElement textElement : allTextViewElements) {
if(textElement.getText().contains("The active connection is")) {
testElement = textElement;
}
diff --git a/junit-5/ios/BStackSampleApp.ipa b/junit-5/ios/BStackSampleApp.ipa
new file mode 100644
index 0000000..c1891b8
Binary files /dev/null and b/junit-5/ios/BStackSampleApp.ipa differ
diff --git a/junit-5/ios/LocalSample.ipa b/junit-5/ios/LocalSample.ipa
new file mode 100644
index 0000000..a937349
Binary files /dev/null and b/junit-5/ios/LocalSample.ipa differ
diff --git a/junit-5/ios/browserstack.yml b/junit-5/ios/browserstack.yml
new file mode 100644
index 0000000..3d79ba1
--- /dev/null
+++ b/junit-5/ios/browserstack.yml
@@ -0,0 +1,77 @@
+# =============================
+# Set BrowserStack Credentials
+# =============================
+# Add your BrowserStack userName and accessKey here or set BROWSERSTACK_USERNAME and
+# BROWSERSTACK_ACCESS_KEY as env variables
+userName: BROWSERSTACK_USERNAME
+accessKey: BROWSERSTACK_ACCESS_KEY
+
+# ======================
+# BrowserStack Reporting
+# ======================
+# The following capabilities are used to set up reporting on BrowserStack:
+# Set 'projectName' to the name of your project. Example, Marketing Website
+projectName: BrowserStack Samples
+# Set `buildName` as the name of the job / testsuite being run
+buildName: browserstack build
+# `buildIdentifier` is a unique id to differentiate every execution that gets appended to
+# buildName. Choose your buildIdentifier format from the available expressions:
+# ${BUILD_NUMBER} (Default): Generates an incremental counter with every execution
+# ${DATE_TIME}: Generates a Timestamp with every execution. Eg. 05-Nov-19:30
+# Read more about buildIdentifiers here -> https://www.browserstack.com/docs/automate/selenium/organize-tests
+buildIdentifier: '#${BUILD_NUMBER}' # Supports strings along with either/both ${expression}
+# Set `framework` of your test suite. Example, `testng`, `cucumber`, `cucumber-testng`
+# This property is needed to send test context to BrowserStack (test name, status)
+framework: junit5
+
+source: junit5:appium-sample-sdk:v1.1
+
+app: ./BStackSampleApp.ipa
+#app: ./LocalSample.ipa #For running local tests
+
+# =======================================
+# Platforms (Browsers / Devices to test)
+# =======================================
+# Platforms object contains all the browser / device combinations you want to test on.
+# Entire list available here -> (https://www.browserstack.com/list-of-browsers-and-platforms/automate)
+
+platforms:
+ - deviceName: iPhone 14 Pro Max
+ platformVersion: 16
+ platformName: ios
+ - deviceName: iPhone 13
+ platformVersion: 15
+ platformName: ios
+ - deviceName: iPhone 15
+ platformVersion: 17
+ platformName: ios
+
+# =======================
+# Parallels per Platform
+# =======================
+# The number of parallel threads to be used for each platform set.
+# BrowserStack's SDK runner will select the best strategy based on the configured value
+#
+# Example 1 - If you have configured 3 platforms and set `parallelsPerPlatform` as 2, a total of 6 (2 * 3) parallel threads will be used on BrowserStack
+#
+# Example 2 - If you have configured 1 platform and set `parallelsPerPlatform` as 5, a total of 5 (1 * 5) parallel threads will be used on BrowserStack
+parallelsPerPlatform: 1
+
+# ==========================================
+# BrowserStack Local
+# (For localhost, staging/private websites)
+# ==========================================
+# Set browserStackLocal to true if your website under test is not accessible publicly over the internet
+# Learn more about how BrowserStack Local works here -> https://www.browserstack.com/docs/automate/selenium/local-testing-introduction
+browserstackLocal: true # (Default false)
+#browserStackLocalOptions:
+#Options to be passed to BrowserStack local in-case of advanced configurations
+# localIdentifier: # (Default: null) Needed if you need to run multiple instances of local.
+# forceLocal: true # (Default: false) Set to true if you need to resolve all your traffic via BrowserStack Local tunnel.
+# Entire list of arguments available here -> https://www.browserstack.com/docs/automate/selenium/manage-incoming-connections
+
+# ===================
+# Debugging features
+# ===================
+debug: false # # Set to true if you need screenshots for every selenium command ran
+networkLogs: false # Set to true to enable HAR logs capturing
diff --git a/junit-5/ios/build.gradle b/junit-5/ios/build.gradle
new file mode 100644
index 0000000..1757ca2
--- /dev/null
+++ b/junit-5/ios/build.gradle
@@ -0,0 +1,51 @@
+plugins {
+ id 'java'
+ id 'com.browserstack.gradle-sdk' version "1.1.2"
+}
+
+repositories { mavenCentral() }
+
+dependencies {
+ testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
+ testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
+ implementation 'commons-io:commons-io:2.11.0'
+ implementation 'org.seleniumhq.selenium:selenium-java:4.4.0'
+ implementation 'io.appium:java-client:8.1.1'
+ implementation 'com.googlecode.json-simple:json-simple:1.1.1'
+ implementation 'com.browserstack:browserstack-java-sdk:latest.release'
+}
+
+group = 'com.browserstack'
+version = '1.0-SNAPSHOT'
+description = 'junit-browserstack'
+sourceCompatibility = '1.8'
+
+def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' }
+
+tasks.withType(JavaCompile) {
+ options.encoding = 'UTF-8'
+}
+
+tasks.withType(Test) {
+ systemProperties = System.properties
+ jvmArgs += "-javaagent:${browserstackSDKArtifact.file}"
+}
+
+task sampleTest(type: Test) {
+ dependsOn cleanTest
+ useJUnitPlatform()
+
+ include 'com/browserstack/FirstTest*'
+
+ jvmArgs "-javaagent:${configurations.testRuntimeClasspath.find { it.name.contains('browserstack-java-sdk') }}"
+}
+
+
+task sampleLocalTest(type: Test) {
+ dependsOn cleanTest
+ useJUnitPlatform()
+
+ include 'com/browserstack/LocalTest*'
+
+ jvmArgs "-javaagent:${configurations.testRuntimeClasspath.find { it.name.contains('browserstack-java-sdk') }}"
+}
diff --git a/ios/junit5-examples/pom.xml b/junit-5/ios/pom.xml
similarity index 62%
rename from ios/junit5-examples/pom.xml
rename to junit-5/ios/pom.xml
index 8041b05..8605e4d 100644
--- a/ios/junit5-examples/pom.xml
+++ b/junit-5/ios/pom.xml
@@ -1,5 +1,5 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.browserstack
@@ -12,64 +12,76 @@
UTF-8
- 2.19.1
-
-
- default
+ 3.0.0-M5
+ com/browserstack/FirstTest.java
org.junit.jupiter
- junit-jupiter-engine
- 5.5.2
+ junit-jupiter-api
+ 5.9.0
test
org.junit.jupiter
- junit-jupiter-params
- 5.5.2
+ junit-jupiter-engine
+ 5.9.0
test
commons-io
commons-io
- 1.3.2
+ 2.11.0
org.seleniumhq.selenium
selenium-java
- 3.141.59
+ 4.4.0
io.appium
java-client
- 7.0.0
-
-
- com.browserstack
- browserstack-local-java
- 1.0.3
+ 8.1.1
com.googlecode.json-simple
json-simple
1.1.1
+
+ com.browserstack
+ browserstack-java-sdk
+ LATEST
+ compile
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ getClasspathFilenames
+
+ properties
+
+
+
+
org.apache.maven.plugins
maven-surefire-plugin
- 2.22.2
+ ${surefire.version}
-
-
- junit.jupiter.execution.parallel.enabled=true
-
-
+
+ ${config.file}
+
+
+ -javaagent:${com.browserstack:browserstack-java-sdk:jar}
+
@@ -86,24 +98,7 @@
- first
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- FirstTest.java
-
-
-
-
-
-
-
-
- parallel
+ sample-test
@@ -111,8 +106,11 @@
maven-surefire-plugin
- ParallelTest.java
+ com/browserstack/FirstTest.java
+
+ -javaagent:${com.browserstack:browserstack-java-sdk:jar}
+
@@ -120,7 +118,7 @@
- local
+ sample-local-test
@@ -128,8 +126,11 @@
maven-surefire-plugin
- LocalTest.java
+ com/browserstack/LocalTest.java
+
+ -javaagent:${com.browserstack:browserstack-java-sdk:jar}
+
diff --git a/junit-5/ios/settings.gradle b/junit-5/ios/settings.gradle
new file mode 100644
index 0000000..3e5b662
--- /dev/null
+++ b/junit-5/ios/settings.gradle
@@ -0,0 +1,15 @@
+pluginManagement {
+ repositories {
+ mavenCentral()
+ mavenLocal()
+ gradlePluginPortal()
+ }
+
+ resolutionStrategy {
+ eachPlugin {
+ if (requested.id.id == "com.browserstack.gradle-sdk") {
+ useModule("com.browserstack:gradle-sdk:1.1.2")
+ }
+ }
+ }
+}
diff --git a/junit-5/ios/src/test/java/com/browserstack/BrowserStackJUnitTest.java b/junit-5/ios/src/test/java/com/browserstack/BrowserStackJUnitTest.java
new file mode 100644
index 0000000..d4bb2c7
--- /dev/null
+++ b/junit-5/ios/src/test/java/com/browserstack/BrowserStackJUnitTest.java
@@ -0,0 +1,63 @@
+package com.browserstack;
+
+import io.appium.java_client.ios.IOSDriver;
+import io.appium.java_client.ios.options.XCUITestOptions;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.nio.file.Files;
+import java.util.*;
+
+public class BrowserStackJUnitTest {
+
+ public IOSDriver driver;
+ public String userName;
+ public String accessKey;
+ public XCUITestOptions options;
+ public static Map browserStackYamlMap;
+ public static final String USER_DIR = "user.dir";
+
+ public BrowserStackJUnitTest() {
+ File file = new File(getUserDir() + "/browserstack.yml");
+ this.browserStackYamlMap = convertYamlFileToMap(file, new HashMap<>());
+ }
+
+ @BeforeEach
+ public void setup() throws Exception {
+ options = new XCUITestOptions();
+ userName = System.getenv("BROWSERSTACK_USERNAME") != null ? System.getenv("BROWSERSTACK_USERNAME") : (String) browserStackYamlMap.get("userName");
+ accessKey = System.getenv("BROWSERSTACK_ACCESS_KEY") != null ? System.getenv("BROWSERSTACK_ACCESS_KEY") : (String) browserStackYamlMap.get("accessKey");
+ options.setCapability("appium:app", "bs://sample.app");
+ options.setCapability("appium:deviceName", "iPhone 14 Pro");
+ options.setCapability("appium:platformVersion", "16");
+
+ driver = new IOSDriver(new URL(String.format("https://%s:%s@hub.browserstack.com/wd/hub", userName , accessKey)), options);
+ }
+
+ @AfterEach
+ public void tearDown() throws Exception {
+ // Invoke driver.quit() to indicate that the test is completed.
+ // Otherwise, it will appear as timed out on BrowserStack.
+ driver.quit();
+ }
+
+ private String getUserDir() {
+ return System.getProperty(USER_DIR);
+ }
+
+ private Map convertYamlFileToMap(File yamlFile, Map map) {
+ try {
+ InputStream inputStream = Files.newInputStream(yamlFile.toPath());
+ Yaml yaml = new Yaml();
+ Map config = yaml.load(inputStream);
+ map.putAll(config);
+ } catch (Exception e) {
+ throw new RuntimeException(String.format("Malformed browserstack.yml file - %s.", e));
+ }
+ return map;
+ }
+}
diff --git a/junit-5/ios/src/test/java/com/browserstack/FirstTest.java b/junit-5/ios/src/test/java/com/browserstack/FirstTest.java
new file mode 100644
index 0000000..0e4c2eb
--- /dev/null
+++ b/junit-5/ios/src/test/java/com/browserstack/FirstTest.java
@@ -0,0 +1,33 @@
+package com.browserstack;
+
+import io.appium.java_client.AppiumBy;
+import org.junit.jupiter.api.Test;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
+import org.openqa.selenium.WebElement;
+
+import java.time.Duration;
+
+import java.io.IOException;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class FirstTest extends BrowserStackJUnitTest{
+
+ @Test
+ void testCalcOne() throws IOException, InterruptedException {
+ WebElement textButton = (WebElement) new WebDriverWait(driver, Duration.ofSeconds(30)).until(
+ ExpectedConditions.elementToBeClickable(AppiumBy.accessibilityId("Text Button")));
+ textButton.click();
+ WebElement textInput = (WebElement) new WebDriverWait(driver, Duration.ofSeconds(30)).until(
+ ExpectedConditions.elementToBeClickable(AppiumBy.accessibilityId("Text Input")));
+ textInput.sendKeys("hello@browserstack.com"+"\n");
+
+ Thread.sleep(5000);
+
+ WebElement textOutput = (WebElement) new WebDriverWait(driver, Duration.ofSeconds(30)).until(
+ ExpectedConditions.elementToBeClickable(AppiumBy.accessibilityId("Text Output")));
+
+ assertEquals(textOutput.getText(),"hello@browserstack.com");
+ }
+}
diff --git a/ios/junit5-examples/src/test/java/com/browserstack/run_local_test/LocalTest.java b/junit-5/ios/src/test/java/com/browserstack/LocalTest.java
similarity index 65%
rename from ios/junit5-examples/src/test/java/com/browserstack/run_local_test/LocalTest.java
rename to junit-5/ios/src/test/java/com/browserstack/LocalTest.java
index b98c607..06aa43a 100644
--- a/ios/junit5-examples/src/test/java/com/browserstack/run_local_test/LocalTest.java
+++ b/junit-5/ios/src/test/java/com/browserstack/LocalTest.java
@@ -1,16 +1,17 @@
-package com.browserstack.run_local_test;
+package com.browserstack;
-import io.appium.java_client.MobileBy;
-import io.appium.java_client.ios.IOSElement;
+import io.appium.java_client.AppiumBy;
import org.apache.commons.io.FileUtils;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.MethodSource;
+import org.junit.jupiter.api.Test;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
+import org.openqa.selenium.WebElement;
+
+import java.time.Duration;
import java.io.File;
import java.io.IOException;
@@ -19,25 +20,22 @@
public class LocalTest extends BrowserStackJUnitTest{
- @ParameterizedTest
- @MethodSource("devices")
- void testCalcOne(int taskId) throws IOException {
-
- createConnection(taskId);
+ @Test
+ void testCalcOne() throws IOException {
- IOSElement testButton = (IOSElement) new WebDriverWait(driver, 30).until(
- ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("TestBrowserStackLocal")));
+ WebElement testButton = (WebElement) new WebDriverWait(driver, Duration.ofSeconds(30)).until(
+ ExpectedConditions.elementToBeClickable(AppiumBy.accessibilityId("TestBrowserStackLocal")));
testButton.click();
- WebDriverWait wait = new WebDriverWait(driver, 30);
+ WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(30));
wait.until(new ExpectedCondition() {
@Override
public Boolean apply(WebDriver d) {
- String result = d.findElement(MobileBy.AccessibilityId("ResultBrowserStackLocal")).getAttribute("value");
+ String result = d.findElement(AppiumBy.accessibilityId("ResultBrowserStackLocal")).getAttribute("value");
return result != null && result.length() > 0;
}
});
- IOSElement resultElement = (IOSElement) driver.findElement(MobileBy.AccessibilityId("ResultBrowserStackLocal"));
+ WebElement resultElement = (WebElement) driver.findElement(AppiumBy.accessibilityId("ResultBrowserStackLocal"));
String resultString = resultElement.getText().toLowerCase();
System.out.println(resultString);