Support for multiple devices in Android

I am trying to run a script on multiple devices on the Andriod platform, but I cannot run. I went through the Github page for the solution and found the following link about Support for multiple (Android) devices from a single Appium server

But, nevertheless, I can not determine the configuration environment for multiple devices.

+4
android appium
source share
5 answers

The following code will help you.

// Run multiple emulators from one application server

public class Test{ WebDriver driver = null; int timeOut=180; int port=-1; Test(int port){ this.port=port; } public void testEmulator(int p) throws Exception { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android"); capabilities.setCapability(CapabilityType.VERSION, "4.3"); capabilities.setCapability(CapabilityType.PLATFORM, "Windows"); capabilities.setCapability("udid","emulator-"+p); capabilities.setCapability("app-package", "your.app.pkg"); capabilities.setCapability("app-activity", "your.app.pkg.Activity"); driver = new RemoteWebDriver(new URL("http://127.0.0.1:"+this.port+"/wd/hub"), capabilities); driver.manage().timeouts().implicitlyWait(timeOut, TimeUnit.SECONDS); Thread.sleep(50000); } public void tearDown() { if (driver != null) driver.quit(); } public void runTest() { try { testEmulator(5554); // for emulator on port 5554 tearDown(); testEmulator(5556); // for emulator on port 5556 tearDown(); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { new Test(4723).runTest(); // appium server port 4723 } } 
+1
source share

Running appium script on multiple devices

  • You need to run appium-servers according to the number of devices with different port numbers.
  • Create a driver instance with each port in your favorite language (java, ruby)
  • Run these script at the same time.
  • You can also create a thread-based program that will create different drivers.

Here I created a simple program based on java stream

https://github.com/sameer49/Appium-Grid-For-Android

+1
source share

For sequential or parallel execution of multiple Android devices, you must -

  • Separate the Appium instance for each device or emulator.
  • For each device instance / Appium provides different values ​​for the Appium port, Bootstrap port, device identifier (i.e. UDID, not device name)
  • Provide a different port for Chrome Driver if you use the Chrome browser in the application

Check the entry below, which uses the Java Thread and Runnable interface for parallel execution - http://automationtestinghub.com/appium-parallel-execution/

+1
source share

If you are talking about a graphical interface, I assume your environment is Windows? Then you can use the following batch:

 @ECHO OFF cd "C:\Program Files (x86)\Appium\node_modules\appium" node server.js --app "<path-to-your-project>\bin\<app-name>.apk" -p <port-to-listen-on> -dp <device-port-to-connect-to-device-on> 

With this, you can run two different Appium servers and use them in parallel.

For a complete list of all available commands, enter node server.js --help .

If you installed Appium through npm, the path to server.js would be something like "C: \ Users \\ AppData \ Roaming \ npm \ node_modules \ appium".

0
source share

For multiple Android devices, start your Appium server with the options:

  • node appium.js -p 4476 -U <device1_serial>
  • node appium.js -p 4475 -U <device2_serial>

You can select any port, but make sure that they are different in your code, where you create the driver, specify the server URL:

 server1_url = "http://127.0.0.1:4475/wd/hub" server2_url = "http://127.0.0.1:4476/wd/hub" 

Done.

0
source share

All Articles