@bhaskar Thanks !
As you mentioned in point no 1:
I am using TestNG (parallel=“tests”) only in my textng.xml
For the point no 2:
I have tried using node port numbers while assigning url to driver.
I think you are saying like below:
driver = new AndroidDriver(new URL(“http://xxxx:5566/wd/hub”), capabilities);
driver = new AndroidDriver(new URL(“http://xxxx:5577/wd/hub”), capabilities);
As the port 4441 is hub port and rest are nodes 5566 and 5577
Ultimately only last driver is considered as previous is/are overwritten and the script gets executed on last one. (i.e. install app on both but executes on one)
I am mentioning hub port number because we load the tests to hub and then hub distributes it to nodes as per the properties set.Please correct me if I am wrong.
Take a look at hub logs, you should have something like this:
INFO org.openqa.grid.web.servlet.handler.RequestHandler - Got a request to create a new session: Capabilities [{browserName=android, … }]
INFO org.openqa.grid.internal.ProxySet - Available nodes: [http://…:5566, http://…:5577, …]
INFO org.openqa.grid.internal.BaseRemoteProxy - Trying to create a new session on node http://…:5566
INFO org.openqa.grid.internal.BaseRemoteProxy - Node http://…:5566 has no matching capability
INFO org.openqa.grid.internal.BaseRemoteProxy - Trying to create a new session on node http://…:5577
INFO org.openqa.grid.internal.TestSlot - Trying to create a new session on test slot {seleniumProtocol=WebDriver, browserName=android, … }
Line 4 occurs when requested capabilities (line 1) don’t match with node capabilities and line 6 occurs when they match.
I think that in your case both requests match with both nodes, so the first node executes the tests in both cases. The hub uses only browserName, version, platform and applicationName capabilities to search the node, and these capabilities are equal in NODE 1 and NODE 2.
Can we achieve parallel testing with one driver object only?
I am referring to device ports directly in the node url while assigning to driver, I think we should load our tests on hub. Please share your thoughts.
Just create a class and use TestNG @BeforeClass annotation, give DesiredCapabilities with specific to AndroidDriver using @Parameters (Those can override in TestNG.xml).
Inside @Test write your script
Call the class file in TestNG xml file as i was mentioned above.
I would like to know “How we can assign multiple urls and different capabilities to a single driver object?”
As we are setting the capabilities as per the device.
If I have to do that I have to give port of HUB that will load the tests over hub and then distribute and apss on to respective nodes. BUT that is not happening as the test only executes over last mentioned device.
I am mentioning driver object and assigning the capabilities as well the url in each IF condition for devices. Which ultimately runs the script on the last assigned device.
A bit urgent for me. (You may mail me the scripts on [email protected])
Thanks in advance !
You can run scripts in parallel by starting multiple appium servers on multiple ports.
But you should create a new Driver object for each device and each url, not try to put it all on the same driver object.