Reputation: 19
enter image description hereOnce the app is launched on multiple android devices. How can we execute same test cases on multiple mobile devices at once? As I am having a bunch of test cases to execute on multiple android devices. I am trying to use For Loop by passing udid OR Appium Server name in Test cases,but it's not working.It executes test case on a single device only.Is there any way using which we can execute test cases (same test cases/test suit) on multiple Android devices at once?
Upvotes: 0
Views: 1655
Reputation: 180
You can use something like following as solution to your problem. As I had said earlier in my answer, you can save the drivers in a dictionary &{drivers}
and use it in your loop to do repetitive actions on all your devices.
*** Settings ***
Library AppiumLibrary
Library Collections
Library Process
*** Variables ***
${APPIUM_SERVER1} http://127.0.0.1:4723/wd/hub
${APPIUM_SERVER2} http://127.0.0.1:4750/wd/hub
${udid_device1} udid of device 1
${udid_device2} udid of device 2
*** Keywords ***
setup and open android phone A
&{drivers}= Create Dictionary
${androiddriver1}= Open Application ${APPIUM_SERVER1} platformName=android platformVersion=7.0 deviceName=android udid=${udid_device1} automationName=uiautomator2
... appPackage=com.android.contacts newCommandTimeout=2500 appActivity=com.android.contacts.activities.PeopleActivity
Set To Dictionary ${drivers} ${udid_device1}=${androiddriver1}
Set suite variable ${drivers}
setup and open android phone B
${androiddriver2}= Open Application ${APPIUM_SERVER2} platformName=android platformVersion=7.0 deviceName=android udid=${udid_device2} automationName=uiautomator2
... appPackage=com.htc.contacts newCommandTimeout=2500 noReset=True appActivity=com.htc.contacts.BrowseLayerCarouselActivity
Set To Dictionary ${drivers} ${udid_device2}=${androiddriver2}
Set suite variable ${drivers}
Log Dictionary ${drivers}
Open URL
:FOR ${key} IN @{drivers.keys()}
\ ${value}= Get From Dictionary ${drivers} ${key}
\ Log ${key}, ${value}
\ repetitive actions here
Upvotes: 1
Reputation: 127
What you basically want to do is Parallel execution of your tests. There are many tools available to achieve this with ease and much coverage (vast number of devices and flavors) like SeeTest Cloud, Xamarin Test Cloud, AWS Device Farm, Perfecto etc
However if you want to achieve using Appium and TestNG it is still possible. Below are high level steps:
Below is the link with exact commands and steps: http://toolsqa.com/mobile-automation/appium/appium-parallel-execution-using-testng/
Upvotes: 1
Reputation: 180
you can save sessions from open application
in a dictionary and use them in a loop to do some actions on every phone.
Please edit your question with code for further help.
Upvotes: 0
Reputation: 4395
You could use https://github.com/mkorpela/pabot with --argumentfile[NUMBER] options.
Upvotes: 1