HI All,
I did browse couple of topic similar to parallel execution on Grid, however , to my surprise, I am not able to perform parallel execution. Please do excuse in advance for opening new thread.
My main confusion is while instantiating Android Driver, which URL do i need to pass
- Grid HUB
- Appium Server (along with different ports as per device)
If i Pass appium server port, code is executed but not in parallel.
I am listing all the necessary details.
- selenium-server-standalone-3.8.1
- java-client 5.0.4
- seleniumjava 3.4.0
COMMAND TO START HUB
java -jar selenium-server-standalone-2.53.0.jar -role hub
NODE CONFIG JSON FOR S7
{
"capabilities":
[
{
"browserName": "Android",
"version":"6.0.1",
"maxInstances": 1,
"platform":"Android",
"deviceName":"84314d5754514830"
}
],
"configuration":
{
"cleanUpCycle":2000,
"timeout":30000,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url":"http://127.0.0.1:4753/wd/hub",
"hub":"127.0.0.1:4444/grid/register",
"host":"127.0.0.1",
"port":4753,
"register":true,
"registerCycle":5000,
"maxSession":6,
"hubPort":4444,
"hubHost":"127.0.0.1"
}
}
NODE CONFIG FOR S8
{
“capabilities”:
[
{
“browserName”: “Android”,
“version”:“7.0”,
“maxInstances”: 1,
“platform”:“ANDROID”,
“deviceName”:“ce031713996be90a01”
}
],
“configuration”:
{
“cleanUpCycle”:2000,
“timeout”:30000,
“proxy”: “org.openqa.grid.selenium.proxy.DefaultRemoteProxy”,
“url”:“http://127.0.0.1:4733/wd/hub”,
“host”:“127.0.0.1”,
“port”:4733,
“register”:true,
“registerCycle”:5000,
“maxSession”:1,
“hubPort”:4444,
“hubHost”:“127.0.0.1”,
“role”:“node”
}
}
COMMAND TO START APPIUM SERVER FOR NODE S7
appium -a 127.0.0.1 -p 4753 --udid 84314d5754514830 --bootstrap-port 4758 --nodeconfig s7.json --session-override &
COMMAND TO START APPIUM SERVER FOR NODE S8
appium -a 127.0.0.1 -p 4733 --udid ce031713996be90a01 --bootstrap-port 4738 --nodeconfig s8.json --session-override &
TESTNG.XML
<suite name="Parallel test suite" verbose="1" parallel="tests" thread-count="5">
<test name="s8">
<parameter name="deviceID" value="ce031713996be90a01"></parameter>
<parameter name="port" value="4733"></parameter>
<parameter name="platform_version" value="7.0"></parameter>
<classes>
<class name="com.demo.AppiumGrid.TestClassTwo" />
</classes>
</test>
<test name="s7">
<parameter name="deviceID" value="84314d5754514830"></parameter>
<parameter name="port" value="4753"></parameter>
<parameter name="platform_version" value="6.0.1"></parameter>
<classes>
<class name="com.demo.AppiumGrid.TestClassTwo" />
</classes>
</test>
</suite>
JAVA CODE
public class TestClassTwo {
AndroidDriver<MobileElement> driver;
static DesiredCapabilities cap = new DesiredCapabilities();
@BeforeTest()
@Parameters({"deviceID","port","platform_version"})
public void setUp(String device,String port, String platform_version) throws MalformedURLException{
File file = new File("src/test/resources/apk/selendroid-test-app-0.17.0.apk");
cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.PLATFORM_NAME , "Android");
cap.setCapability(MobileCapabilityType.PLATFORM_VERSION, platform_version);
cap.setCapability(MobileCapabilityType.DEVICE_NAME, device);
cap.setCapability(MobileCapabilityType.APP, file);
cap.setCapability("appPackage", "io.selendroid.testapp");
cap.setCapability("appActivity", "io.selendroid.testapp.HomeScreenActivity");
URL url = new URL("http://localhost:"+port+"/wd/hub");
driver = new AndroidDriver<MobileElement>(url, cap);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
@Test(priority =1)
public void testA(){
System.out.println("ThreadName: " + Thread.currentThread().getName() + Thread.currentThread().getStackTrace()[1].getClassName());
}
@AfterTest
public void tearDown(){
driver.quit();
}
Tagging few members whom I see were able to run test cases in parallel.
Guys , if possible, please help me
@Hassan_Radi @Priyank_Shah @Arvind_Patel1 @Free_Automation , @Appium_Master @bhaskar