Can you Please suggest how to run multiple device with different session and with different port . we can’t able to make it .
Please help us to make it possible
So you could do this manually, via script, CI tool or using java.
My java example, it’s not the best solution ever, however it may helps you:
public void startAppium() {
//start appium instance
try {
Thread.sleep((long)(Math.random() * 10000)); //wait from 0 to 10 sec for parallel process run
ProcessBuilder builder = new ProcessBuilder(getCmd());
builder.redirectOutput("path to log file"); //here you can find logs of appium
builder.redirectErrorStream(true);
appium = builder.start();
Thread.sleep(3000); //wait 3 sec until server started
} catch (Exception e) {
e.printStackTrace();
}
}
private List getCmd(){
//create cmd by adding each param
List cmd = new ArrayList();
cmd.add(“node”);
cmd.add(“path to appium folder”);
cmd.add("-a");
cmd.add(“ip address”);
cmd.add("-p");
cmd.add(“appium port”);
cmd.add("-bp");
cmd.add(“bootstrap port”);
cmd.add("-U");
cmd.add(“udid”);
cmd.add("–chromedriver-port");
cmd.add(“chrome port”);
return cmd;
}
public void stopAppium(){
//stop appium instance
appium.destroy();
}
If you don’t want to set up (and administrate) different appium endpoints in your test project, you may want to give a try to this tool I wrote: Appium Proxy.
Basically, it’s a python script that starts a web proxy, hooks to session creation requests and distributes the handling of the sessions among different appium server instances. So you can use a single endpoint in your tests configuration.
It’s just a PoC but works for me (at least for what I need).
Hi @UD,
Were you able to run tests on multiple devices. I need to run mobile web test on android phone as well as on iPhone. So is there any way to do so parallely?
I am trying to run a test script written in ruby on multiple devices.
I am not able to run the scripts in parallel.
what I have tried:
launch and start multiple appium server isntances with different ports (appium port, chromedriver, bootstrap-port & selendroid-port.
this works fine and servers have started
however when I create driver, multiple drivers are created, but test script runs on only the first device (first device detected on adb) , it never runs on the second device.
this is how I start the server:
node.exe Appium.js --address 127.0.0.1 --port # {a} --chromedriver-port --bootstrap-port # {} --selendroid-port #{} --device-name F9AZCY00U236 --no-reset --local-timezone"
You need to make sure that you pass device UDID (or device Id), and not the deviceName property. Appium can distinguish between devices only when you provide UDID. Check the code in the below article. It will give an idea of how this can be done. You can implement it with Java Thread, TestNG or any other way you want.