I'm new with Appium and trying to run 2 android devices using Appium and Selenium (Java) parallel but only 1 device is running my test script. Below is my test script (junit) and having hard time trying to work this out. I'm not using any Grid or Cloud Grid (SauceLabs/BrowserStack) for the mean time as I'd like to monitor this locally for now.
public class StartChrome {
public WebDriver driver;
@Before
public void setUp() throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("automationName", "Appium");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "7.0");
capabilities.setCapability("browserName", "Chrome");
capabilities.setCapability("deviceName", "Phone's Name");
URL url = new URL("http://127.0.0.1:4723/wd/hub");
driver = new RemoteWebDriver(url, capabilities);
}
@Test
public void test() {
driver.get("http://saucelabs.com/test/guinea-pig");
WebElement div = driver.findElement(By.id("i_am_an_id"));
Assert.assertEquals("I am a div", div.getText());
driver.findElement(By.id("comments")).sendKeys("My comment");
}
@After
public void tearDown() {
driver.quit();
}
I'm not really sure what details I need to add here but I'm happy to answer anything and and advice would be very much appreciated.
Thanks in advance!!
First You need to start two appium servers on diffrent ports. Then you use that URL for both of your scripts and run them in parallel using TesNg.