├── .gitpod.yml ├── README.md ├── pom.xml ├── src └── test │ └── java │ └── com │ └── lambdatest │ ├── android.java │ └── ios.java └── target ├── lambdatest-junit-sample-1.0-SNAPSHOT.jar ├── maven-archiver └── pom.properties ├── maven-status └── maven-compiler-plugin │ └── testCompile │ └── default-testCompile │ └── createdFiles.lst └── test-classes └── com └── lambdatest ├── android.class └── ios.class /.gitpod.yml: -------------------------------------------------------------------------------- 1 | # This configuration file was automatically generated by Gitpod. 2 | # Please adjust to your needs (see https://www.gitpod.io/docs/config-gitpod-file) 3 | # and commit this file to your remote git repository to share the goodness with others. 4 | 5 | tasks: 6 | - init: mvn install -DskipTests=false 7 | 8 | 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # How to install multiple apps in Real Devices on [LambdaTest](https://www.lambdatest.com/?utm_source=github&utm_medium=repo&utm_campaign=appium-junit-multipleApps) using the Appium Java Junit Framework 2 | 3 | While performing app automation testing with appium on LambdaTest Grid, you might face a scenario where the APP1 that you are testing needs to interact with a few other applications APP2, APP3. In this scenario, LambdaTest offers an easy way out where you can just [upload your apps](https://www.lambdatest.com/support/docs/appium-java/#upload-your-application) & add them to the multiple apps array. 4 | It becomes extremely convenient now where you can just add those URLs & run your tests with ease. 5 | 6 | # Steps: 7 | 8 | You can add the app URLs fetched by [uploading your apps](https://www.lambdatest.com/support/docs/appium-java/#upload-your-application) in the ```otherApps``` capability. 9 | 10 | You can make this change in the ```android.java``` and ```ios.java```: 11 | 12 | Below is the ```android.java``` example shown: 13 | 14 | ```java 15 | public class android { 16 | String username = System.getenv("LT_USERNAME") == null ? "LT_USERNAME" //Enter the Username here 17 | : System.getenv("LT_USERNAME"); 18 | String accessKey = System.getenv("LT_ACCESS_KEY") == null ? "LT_ACCESS_KEY" //Enter the Access key here 19 | : System.getenv("LT_ACCESS_KEY"); 20 | public static RemoteWebDriver driver = null; 21 | public String gridURL = "@beta-hub.lambdatest.com/wd/hub"; 22 | public String status = "passed"; 23 | @Before 24 | public void setUp() throws Exception { 25 | DesiredCapabilities capabilities = new DesiredCapabilities(); 26 | capabilities.setCapability("build", "JUNIT Native App automation"); 27 | capabilities.setCapability("name", "Java JUnit Android Pixel 6"); 28 | capabilities.setCapability("platformName", "android"); 29 | capabilities.setCapability("deviceName", "Pixel 6"); //Enter the name of the device here 30 | capabilities.setCapability("isRealMobile", true); 31 | capabilities.setCapability("platformVersion","12"); 32 | capabilities.setCapability("app","lt://"); //Enter the App ID here 33 | capabilities.setCapability("deviceOrientation", "PORTRAIT"); 34 | capabilities.setCapability("console",true); 35 | capabilities.setCapability("network",true); 36 | capabilities.setCapability("visual",true); 37 | 38 | // ADD THE APP URL OF OTHER APPS THAT YOU'D LIKE TO INSTALL ON THE SAME DEVICE 39 | capabilities.setCapability("otherApps", "[\"APP_ID\", \"APP_ID\"]"); // ENTER THE OTHER APP URLs HERE IN AN ARRAY FORMAT 40 | 41 | try 42 | { 43 | driver = new RemoteWebDriver(new URL("https://" + username + ":" + accessKey + gridURL), capabilities); 44 | } 45 | catch (MalformedURLException e) 46 | { 47 | System.out.println("Invalid grid URL"); 48 | } catch (Exception e) 49 | { 50 | System.out.println(e.getMessage()); 51 | } 52 | } 53 | @Test 54 | public void testSimple() throws Exception 55 | { 56 | try 57 | { 58 | WebDriverWait wait = new WebDriverWait(driver, 30); 59 | wait.until(ExpectedConditions.elementToBeClickable(MobileBy.id("color"))).click(); 60 | wait.until(ExpectedConditions.elementToBeClickable(MobileBy.id("geoLocation"))).click();; 61 | Thread.sleep(5000); 62 | driver.navigate().back(); 63 | wait.until(ExpectedConditions.elementToBeClickable(MobileBy.id("Text"))).click(); 64 | wait.until(ExpectedConditions.elementToBeClickable(MobileBy.id("notification"))).click();; 65 | wait.until(ExpectedConditions.elementToBeClickable(MobileBy.id("toast"))).click(); 66 | status="passed"; 67 | } 68 | catch (Exception e) 69 | { 70 | System.out.println(e.getMessage()); 71 | status="failed"; 72 | } 73 | } 74 | @After 75 | public void tearDown() throws Exception 76 | { 77 | if (driver != null) 78 | { 79 | driver.executeScript("lambda-status=" + status); 80 | driver.quit(); 81 | } 82 | } 83 | } 84 | ``` 85 | 86 | ## Executing The Test 87 | 88 | Execute the following commands to install the required dependencies: 89 | 90 | ```bash 91 | mvn clean 92 | ``` 93 | 94 | The tests can be executed in the terminal using the following command: 95 | 96 | ```bash 97 | mvn test -P android 98 | ``` 99 | 100 | ```bash 101 | mvn test -P ios 102 | ``` 103 | 104 | **Info:** Your test results would be displayed on the test console (or command-line interface if you are using terminal/cmd) and on the :link: [LambdaTest App Automation Dashboard](https://appautomation.lambdatest.com/build?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-java-junit). 105 | 106 | 107 | 108 | Your test results would be displayed on the test console (or command-line interface if you are using terminal/cmd) and on the [LambdaTest App Automation Dashboard](https://appautomation.lambdatest.com/build). 109 | 110 | ## Additional Links 111 | 112 | - [Advanced Configuration for Capabilities](https://www.lambdatest.com/support/docs/desired-capabilities-in-appium/?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-java-junit) 113 | - [How to test locally hosted apps](https://www.lambdatest.com/support/docs/testing-locally-hosted-pages/?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-java-junit) 114 | - [How to integrate LambdaTest with CI/CD](https://www.lambdatest.com/support/docs/integrations-with-ci-cd-tools/?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-java-junit) 115 | 116 | ## Documentation & Resources :books: 117 | 118 | Visit the following links to learn more about LambdaTest's features, setup and tutorials around test automation, mobile app testing, responsive testing, and manual testing. 119 | 120 | * [LambdaTest Documentation](https://www.lambdatest.com/support/docs/?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-python) 121 | * [LambdaTest Blog](https://www.lambdatest.com/blog/?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-python) 122 | * [LambdaTest Learning Hub](https://www.lambdatest.com/learning-hub/?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-python) 123 | * [LambdaTest Community](http://community.lambdatest.com/) 124 | 125 | ## LambdaTest Community :busts_in_silhouette: 126 | 127 | The [LambdaTest Community](https://community.lambdatest.com/?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-java-junit) allows people to interact with tech enthusiasts. Connect, ask questions, and learn from tech-savvy people. Discuss best practises in web development, testing, and DevOps with professionals from across the globe 🌎 128 | 129 | ## What's New At LambdaTest ❓ 130 | 131 | To stay updated with the latest features and product add-ons, visit [Changelog](https://changelog.lambdatest.com/) 132 | 133 | ## About LambdaTest 134 | 135 | [LambdaTest](https://www.lambdatest.com?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-java-junit) is a leading test execution and orchestration platform that is fast, reliable, scalable, and secure. It allows users to run both manual and automated testing of web and mobile apps across 3000+ different browsers, operating systems, and real device combinations. Using LambdaTest, businesses can ensure quicker developer feedback and hence achieve faster go to market. Over 500 enterprises and 1 Million + users across 130+ countries rely on LambdaTest for their testing needs. 136 | 137 | ### Features 138 | 139 | * Run Selenium, Cypress, Puppeteer, Playwright, and Appium automation tests across 3000+ real desktop and mobile environments. 140 | * Real-time cross browser testing on 3000+ environments. 141 | * Test on Real device cloud 142 | * Blazing fast test automation with HyperExecute 143 | * Accelerate testing, shorten job times and get faster feedback on code changes with Test At Scale. 144 | * Smart Visual Regression Testing on cloud 145 | * 120+ third-party integrations with your favorite tool for CI/CD, Project Management, Codeless Automation, and more. 146 | * Automated Screenshot testing across multiple browsers in a single click. 147 | * Local testing of web and mobile apps. 148 | * Online Accessibility Testing across 3000+ desktop and mobile browsers, browser versions, and operating systems. 149 | * Geolocation testing of web and mobile apps across 53+ countries. 150 | * LT Browser - for responsive testing across 50+ pre-installed mobile, tablets, desktop, and laptop viewports 151 | 152 | [](https://accounts.lambdatest.com/register) 153 | 154 | ## We are here to help you :headphones: 155 | 156 | * Got a query? we are available 24x7 to help. [Contact Us](support@lambdatest.com) 157 | * For more info, visit - [LambdaTest](https://www.lambdatest.com/?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-java-junit-multipleApps) -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.lambdatest 8 | lambdatest-junit-sample 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 13 | 14 | 15 | 16 | UTF-8 17 | 2.19.1 18 | 19 | 20 | default 21 | 22 | 23 | 24 | 25 | junit 26 | junit 27 | 4.12 28 | test 29 | 30 | 31 | commons-io 32 | commons-io 33 | 1.3.2 34 | test 35 | 36 | 37 | org.seleniumhq.selenium 38 | selenium-java 39 | 3.141.59 40 | test 41 | 42 | 43 | com.googlecode.json-simple 44 | json-simple 45 | 1.1.1 46 | test 47 | 48 | 49 | io.appium 50 | java-client 51 | 6.1.0 52 | test 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | maven-compiler-plugin 62 | 3.0 63 | 64 | 1.8 65 | 1.8 66 | 67 | 68 | 69 | 70 | 71 | org.apache.maven.plugins 72 | maven-surefire-plugin 73 | 2.12.4 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | parallel 82 | 83 | 84 | 85 | org.apache.maven.plugins 86 | maven-surefire-plugin 87 | 88 | 89 | com/lambdatest/JUnitConcurrentTodo.java 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | single 99 | 100 | 101 | 102 | org.apache.maven.plugins 103 | maven-surefire-plugin 104 | 105 | 106 | com/lambdatest/NativeApp.java 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /src/test/java/com/lambdatest/android.java: -------------------------------------------------------------------------------- 1 | package com.lambdatest; 2 | 3 | import io.appium.java_client.MobileBy; 4 | import org.junit.After; 5 | import org.junit.Before; 6 | import org.junit.Test; 7 | import org.openqa.selenium.remote.DesiredCapabilities; 8 | import org.openqa.selenium.remote.RemoteWebDriver; 9 | import org.openqa.selenium.By; 10 | 11 | import org.openqa.selenium.support.ui.ExpectedConditions; 12 | import org.openqa.selenium.support.ui.WebDriverWait; 13 | 14 | import java.net.MalformedURLException; 15 | import java.net.URL; 16 | 17 | public class android { 18 | String username = System.getenv("LT_USERNAME") == null ? "LT_USERNAME" //Enter the Username here 19 | : System.getenv("LT_USERNAME"); 20 | String accessKey = System.getenv("LT_ACCESS_KEY") == null ? "LT_ACCESS_KEY" //Enter the Access key here 21 | : System.getenv("LT_ACCESS_KEY"); 22 | public static RemoteWebDriver driver = null; 23 | public String gridURL = "@mobile-hub.lambdatest.com/wd/hub"; 24 | public String status = "passed"; 25 | @Before 26 | public void setUp() throws Exception { 27 | DesiredCapabilities capabilities = new DesiredCapabilities(); 28 | 29 | capabilities.setCapability("build", "JUNIT Native App automation"); 30 | capabilities.setCapability("name", "Java JUnit Android Pixel 6"); 31 | capabilities.setCapability("platformName", "android"); 32 | capabilities.setCapability("deviceName", "Pixel 6"); 33 | capabilities.setCapability("isRealMobile", true); 34 | capabilities.setCapability("platformVersion","12"); 35 | capabilities.setCapability("app","lt://"); //Enter the App ID here 36 | capabilities.setCapability("deviceOrientation", "PORTRAIT"); 37 | capabilities.setCapability("console",true); 38 | capabilities.setCapability("network",true); 39 | capabilities.setCapability("visual",true); 40 | 41 | // ADD THE APP URL OF OTHER APPS THAT YOU'D LIKE TO INSTALL ON THE SAME DEVICE 42 | capabilities.setCapability("otherApps", "[\"APP_ID\", \"APP_ID\"]"); // ENTER THE OTHER APP URLs HERE IN AN ARRAY FORMAT 43 | 44 | 45 | try 46 | { 47 | driver = new RemoteWebDriver(new URL("https://" + username + ":" + accessKey + gridURL), capabilities); 48 | } 49 | catch (MalformedURLException e) 50 | { 51 | System.out.println("Invalid grid URL"); 52 | } catch (Exception e) 53 | { 54 | System.out.println(e.getMessage()); 55 | } 56 | } 57 | 58 | @Test 59 | public void testSimple() throws Exception 60 | { 61 | try 62 | { 63 | WebDriverWait wait = new WebDriverWait(driver, 30); 64 | wait.until(ExpectedConditions.elementToBeClickable(MobileBy.id("color"))).click(); 65 | 66 | wait.until(ExpectedConditions.elementToBeClickable(MobileBy.id("geoLocation"))).click();; 67 | Thread.sleep(5000); 68 | driver.navigate().back(); 69 | 70 | wait.until(ExpectedConditions.elementToBeClickable(MobileBy.id("Text"))).click(); 71 | 72 | wait.until(ExpectedConditions.elementToBeClickable(MobileBy.id("notification"))).click();; 73 | 74 | wait.until(ExpectedConditions.elementToBeClickable(MobileBy.id("toast"))).click(); 75 | 76 | status="passed"; 77 | } 78 | catch (Exception e) 79 | { 80 | System.out.println(e.getMessage()); 81 | status="failed"; 82 | } 83 | } 84 | @After 85 | public void tearDown() throws Exception 86 | { 87 | if (driver != null) 88 | { 89 | driver.executeScript("lambda-status=" + status); 90 | driver.quit(); 91 | } 92 | } 93 | } -------------------------------------------------------------------------------- /src/test/java/com/lambdatest/ios.java: -------------------------------------------------------------------------------- 1 | package com.lambdatest; 2 | 3 | import io.appium.java_client.MobileBy; 4 | import org.junit.After; 5 | import org.junit.Before; 6 | import org.junit.Test; 7 | import org.openqa.selenium.remote.DesiredCapabilities; 8 | import org.openqa.selenium.remote.RemoteWebDriver; 9 | import org.openqa.selenium.By; 10 | 11 | import org.openqa.selenium.support.ui.ExpectedConditions; 12 | import org.openqa.selenium.support.ui.WebDriverWait; 13 | 14 | import java.net.MalformedURLException; 15 | import java.net.URL; 16 | 17 | public class ios { 18 | String username = System.getenv("LT_USERNAME") == null ? "LT_USERNAME" //Enter the Username here 19 | : System.getenv("LT_USERNAME"); 20 | String accessKey = System.getenv("LT_ACCESS_KEY") == null ? "LT_ACCESS_KEY" //Enter the Access key here 21 | : System.getenv("LT_ACCESS_KEY"); 22 | public static RemoteWebDriver driver = null; 23 | public String gridURL = "@mobile-hub.lambdatest.com/wd/hub"; 24 | public String status = "passed"; 25 | @Before 26 | public void setUp() throws Exception { 27 | DesiredCapabilities capabilities = new DesiredCapabilities(); 28 | 29 | capabilities.setCapability("build", "JUNIT Native App automation"); 30 | capabilities.setCapability("name", "Java JUnit iOS iPhone 12"); 31 | capabilities.setCapability("platformName", "ios"); 32 | capabilities.setCapability("deviceName", "iPhone 12"); 33 | capabilities.setCapability("isRealMobile", true); 34 | capabilities.setCapability("platformVersion","15"); 35 | capabilities.setCapability("app","lt://"); //Enter the APP_ID here 36 | capabilities.setCapability("deviceOrientation", "PORTRAIT"); 37 | capabilities.setCapability("console",true); 38 | capabilities.setCapability("network",true); 39 | capabilities.setCapability("visual",true); 40 | 41 | // ADD THE APP URL OF OTHER APPS THAT YOU'D LIKE TO INSTALL ON THE SAME DEVICE 42 | capabilities.setCapability("otherApps", "[\"APP_ID\", \"APP_ID\"]"); // ENTER THE OTHER APP URLs HERE IN AN ARRAY FORMAT 43 | 44 | 45 | try 46 | { 47 | driver = new RemoteWebDriver(new URL("https://" + username + ":" + accessKey + gridURL), capabilities); 48 | } 49 | catch (MalformedURLException e) 50 | { 51 | System.out.println("Invalid grid URL"); 52 | } catch (Exception e) 53 | { 54 | System.out.println(e.getMessage()); 55 | } 56 | } 57 | 58 | @Test 59 | public void testSimple() throws Exception 60 | { 61 | try 62 | { 63 | WebDriverWait wait = new WebDriverWait(driver, 30); 64 | wait.until(ExpectedConditions.elementToBeClickable(MobileBy.id("color"))).click(); 65 | 66 | wait.until(ExpectedConditions.elementToBeClickable(MobileBy.id("geoLocation"))).click(); 67 | Thread.sleep(5000); 68 | driver.navigate().back(); 69 | 70 | wait.until(ExpectedConditions.elementToBeClickable(MobileBy.id("Text"))).click(); 71 | 72 | wait.until(ExpectedConditions.elementToBeClickable(MobileBy.id("notification"))).click(); 73 | 74 | status="passed"; 75 | } 76 | catch (Exception e) 77 | { 78 | System.out.println(e.getMessage()); 79 | status="failed"; 80 | } 81 | } 82 | @After 83 | public void tearDown() throws Exception 84 | { 85 | if (driver != null) 86 | { 87 | driver.executeScript("lambda-status=" + status); 88 | driver.quit(); 89 | } 90 | } 91 | } -------------------------------------------------------------------------------- /target/lambdatest-junit-sample-1.0-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/himanshuseth004/junit-appium-multiple-apps/7ff52fc763c65f5cf7baf74b2642eeb3fa210662/target/lambdatest-junit-sample-1.0-SNAPSHOT.jar -------------------------------------------------------------------------------- /target/maven-archiver/pom.properties: -------------------------------------------------------------------------------- 1 | #Generated by Maven 2 | #Thu Jun 23 07:34:53 UTC 2022 3 | groupId=com.lambdatest 4 | artifactId=lambdatest-junit-sample 5 | version=1.0-SNAPSHOT 6 | -------------------------------------------------------------------------------- /target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst: -------------------------------------------------------------------------------- 1 | com/lambdatest/android.class 2 | com/lambdatest/ios.class 3 | -------------------------------------------------------------------------------- /target/test-classes/com/lambdatest/android.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/himanshuseth004/junit-appium-multiple-apps/7ff52fc763c65f5cf7baf74b2642eeb3fa210662/target/test-classes/com/lambdatest/android.class -------------------------------------------------------------------------------- /target/test-classes/com/lambdatest/ios.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/himanshuseth004/junit-appium-multiple-apps/7ff52fc763c65f5cf7baf74b2642eeb3fa210662/target/test-classes/com/lambdatest/ios.class --------------------------------------------------------------------------------