Tried to setup parallel execution with selenium grid for two android emulators. But My tests firstly run on 1 device, after finishing, they starts on the 2 device.
Please help, how to run test simultaneously on two devices.
How I run it.
-
Creating Hub. java -jar selenium-server-standalone-3.14.0.jar -role hub -port 4445
-
Launching two emulators. with command adb devices i found their udid.
-
Run 2 appium servers.
appium --nodeconfig ~/pathtonode/node_1 -p 4724 --suppress-adb-kill-server --bootstrap-port 4824 -U emulator-5554
appium --nodeconfig ~/TeamWorkAndroid/src/main/resources/appium_node_config/node_2 -p 4734 --suppress-adb-kill-server --bootstrap-port 4834 -U emulator-5556
This is my nodes.
{
"capabilities":
[
{
"browserName":"Android Nexus4",
"version":"7.1.1",
"platform":"ANDROID",
"maxInstances": 1
}
],
"configuration":
{
"cleanUpCycle":2000,
"timeout":30000,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url": "http://127.0.0.1:4724/wd/hub",
"host": "127.0.0.1",
"port": 4724,
"maxSession": 1,
"register": true,
"registerCycle": 5000,
"hubPort": 4445,
"hubHost": "127.0.0.1",
"session-override": true
}
}
{
“capabilities”:
[
{
“browserName”:“Android Pixel”,
“version”:“5.1.1”,
“platform”:“ANDROID”,
“maxInstances”: 1
}
],
“configuration”:
{
“cleanUpCycle”:2000,
“timeout”:30000,
“proxy”: “org.openqa.grid.selenium.proxy.DefaultRemoteProxy”,
“url”: “http://127.0.0.1:4734/wd/hub”,
“host”: “127.0.0.1”,
“port”: 4734,
“maxSession”: 1,
“register”: true,
“registerCycle”: 5000,
“hubPort”: 4445,
“hubHost”: “127.0.0.1”,
“session-override”: true
}
}
My testng.xml.
<?xml version="1.0" encoding="UTF-8"?>
<test name="Nexus 5X">
<parameter name="platform" value="android"/>
<parameter name="udid" value="emulator-5554"/>
<parameter name="platformVersion" value="7.1.1"/>
<parameter name="noReset" value="false"/>
<classes>
<class name="testClasses.android.VerifyOnboardingScreen"/>
</classes>
</test>
<test name ="Emulator2">
<parameter name="platform" value="android"/>
<parameter name="udid" value="emulator-5556"/>
<parameter name="platformVersion" value="5.1.1"/>
<parameter name="noReset" value="false"/>
<classes>
<class name="testClasses.android.VerifyOnboardingScreen"/>
</classes>
</test>
Method where driver starts.
@Parameters({"platform", "udid", "platformVersion", "noReset"})
@BeforeMethod(alwaysRun = true)
public void setUp
(
String platform,
String udid,
String platformVersion,
String noReset
) throws Exception {
String resourcesPath = new File("src/main/resources/app").getAbsolutePath();
DesiredCapabilities capabilities = new DesiredCapabilities();
switch (platform.toLowerCase()) {
case "android":
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android");
capabilities.setCapability(MobileCapabilityType.UDID, udid);
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, platformVersion);
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
capabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "co.app");
capabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, "co.app.GCSplashActivity");
capabilities.setCapability("automationName", "uiautomator2");
capabilities.setCapability("app", resourcesPath + "/android/app.apk");
driver = new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:4445/wd/hub"), capabilities);
configureDriver();
break;