Tiago Mateus
Tiago Mateus

Reputation: 61

Running multiple Appium sessions in a single test

I am automating some tests on real devices using Appium and Cucumber and at the moment I am trying to run 2 Appium sessions a single test, something like:

I am wondering what would be the correct way to implement this in Ruby.

Anyone with experience have any tips/advice or some code examples? Or simply redirect me to some good documentation or code.

Upvotes: 1

Views: 2665

Answers (1)

barbudito
barbudito

Reputation: 578

  1. If you want them to run at the same time you will need to create X "node appium" executions with different ports...

Example:

node appium -p 4723 -bp 4724 -U "Device1_identifier"
node appium -p 4725 -bp 4726 -U "Device2_identifier"

And after that you will have to create two drivers

Java code

DesiredCapabilities capabilities1 = new DesiredCapabilities();
capabilities1.setCapability(...);
driver= new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities1);

DesiredCapabilities capabilities2 = new DesiredCapabilities();
capabilities2.setCapability(...);
driver2= new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4725/wd/hub"), capabilities2);
  1. You could create just one appium server with this argument to override sessions:

Example:

node appium --session-override

And then create a second driver with another capabilities after the you finished with first one...

Java code

DesiredCapabilities capabilities1 = new DesiredCapabilities();
capabilities1.setCapability("udid", "Device1_identifier"); //Not necessary if execution is at the same device
capabilities1.setCapability(...);
driver= new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities1);
//DO THINGS WITH DRIVER HERE  
driver.findElement...
driver.something...
////////////////////////////  

DesiredCapabilities capabilities2 = new DesiredCapabilities();
capabilities2.setCapability("udid", "Device2_identifier"); //Not necessary if execution is at the same device
capabilities2.setCapability(...);
driver= new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities2); //This will override your first Appium driver

Upvotes: 2

Related Questions