@jonahss : When can we have 1.5? Would be great to have for parallel testing.

@bhaskar @Appium_Master @rgonalo @Hassan_Radi @jonahss @Arvind_Patel
Really looking forward for solution to run scripts parallel. 
I am able to run sequential and have done the changes suggested by @bhaskar.
@bootstraponline will this help to bring up parallel iOS simulator
Yes, Facebook has figured out how to do parallel iOS simulators. I've opened an issue on appium to adopt this new tool60.
Hi @bootstraponline and @saikrishna321 ,
Did you achieved parallel execution on IOS devices/simulators ? Please let us know.
Thanks,
Bhaskar.
Facebook figured it out with https://github.com/facebook/WebDriverAgent64 plus https://github.com/facebook/FBSimulatorControl34
Appium integration is being worked on.
@bootstraponline i was able to spin up two iOS Simulators, from commandline can i tell appium to run against a specific UDID ??
Steps to get two simulators
xcrun simctl create "mynewsimulator" "iPhone 6" "com.apple.CoreSimulator.SimRuntime.iOS-8-4"
open -n /Applications/Xcode.app/Contents/Developer/Applications/iOS\ Simulator.app/ --args -CurrentDeviceUDID '0F3826F2-2C2A-47E2-869C-7CE043C12F81'
See --udid https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/server-args.md68
I think you'll need to change the ports as well (different for each instance).
@Simon_K @bootstraponline, how do i provide the tmp directories ?
package com.naukri.androidApp.TestSuite;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;
import GenericFunctionsLibrary.GenericFunctions;
import com.naukri.androidApp.Code.SplashScreen;
import com.naukri.androidApp.ConfigDetails.Config;
public class ParallelExecution01 extends Config{
public AndroidDriver driver01;
public AndroidDriver driver02;
public void StartDriver01()
{
try {
File file = new File("<apk path>");
String appPath = file.getAbsolutePath();
//G2
driver01 = this.StartDriverAndroidApp01(appPath, appPackage, appActivity, "ZX1D64QFK6");
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
@SuppressWarnings("null")
public AndroidDriver StartDriverAndroidApp01(String appLocation, String appPackage, String appActivity, String deviceName) throws MalformedURLException{
try{Thread.sleep(5000);}catch(Exception e){}
appPackage = Config.appPackage;
appActivity = Config.appActivity;
DesiredCapabilities capabilities = new DesiredCapabilities();
ThreadLocal<AndroidDriver> threadDriver = null;
//For device 1
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "ANDROID");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "5.0.2");
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, deviceName);
capabilities.setCapability(MobileCapabilityType.APP, appLocation);
capabilities.setCapability(MobileCapabilityType.APP_PACKAGE, appPackage);
capabilities.setCapability(MobileCapabilityType.APP_ACTIVITY, appActivity);
try {
System.setProperty("webdriver.ie.driver", "C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe");
driver01 = new AndroidDriver(new URL("http://127.0.0.1:4444/wd/hub"), capabilities);
threadDriver.set((AndroidDriver) driver01);
} catch (MalformedURLException e) {
e.printStackTrace();
}
System.out.println("========driver after launching app========" + driver );
driver01.manage().timeouts().implicitlyWait(60000, TimeUnit.MILLISECONDS);
System.out.println("==========complete launchApp========");
return threadDriver.get();
}
public void StartDriver02()
{
try {
File file = new File("<apk path>");
String appPath = file.getAbsolutePath();
//S3
driver02 = this.StartDriverAndroidApp02(appPath, appPackage, appActivity, "4df707995bd4215b");
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
@SuppressWarnings("null")
public AndroidDriver StartDriverAndroidApp02(String appLocation, String appPackage, String appActivity, String deviceName) throws MalformedURLException{
try{Thread.sleep(5000);}catch(Exception e){}
//appLocation = Config.appLocation;
appPackage = Config.appPackage;
appActivity = Config.appActivity;
DesiredCapabilities capabilities = new DesiredCapabilities();
//DesiredCapabilities capabilities1 = new DesiredCapabilities();
ThreadLocal<AndroidDriver> threadDriver = null;
//For device 1
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "ANDROID");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "4.3");
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, deviceName);
capabilities.setCapability(MobileCapabilityType.APP, appLocation);
capabilities.setCapability(MobileCapabilityType.APP_PACKAGE, appPackage);
capabilities.setCapability(MobileCapabilityType.APP_ACTIVITY, appActivity);
try {
System.setProperty("webdriver.ie.driver", "C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe");
driver02 = new AndroidDriver(new URL("http://127.0.0.1:4444/wd/hub"), capabilities);
threadDriver.set((AndroidDriver) driver02);
} catch (MalformedURLException e) {
e.printStackTrace();
}
System.out.println("========driver after launching app========" + driver02 );
driver02.manage().timeouts().implicitlyWait(60000, TimeUnit.MILLISECONDS);
System.out.println("==========complete launchApp========");
return threadDriver.get();
}
@Test
public void TC_01() {
this.StartDriver01();
SplashScreen splash = new SplashScreen(driver01, null);
splash.ClickOnSearchJobsButton();
}
@Test
public void TC_02() {
this.StartDriver02();
SplashScreen splash = new SplashScreen(driver02, null);
splash.ClickOnLoginButton();
}
}
My Config files for hub and node are as follows:
Hub:
{
"url":"http://127.0.0.1:4444/wd/hub",
"host": 127.0.0.1,
"port": 4444,
"newSessionWaitTimeout": -1,
"servlets" : [],
"prioritizer": null,
"capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
"throwOnCapabilityNotPresent": true,
"nodePolling": 5000,
"cleanUpCycle": 5000,
"timeout": 300000,
"maxSession": 5
}
Node files:
{
"capabilities":
[
{
"browserName": "ANDROID",
"version":"4.3",
"maxInstances": 1,
"platform":"ANDROID"
}
],
"configuration":
{
"cleanUpCycle":2000,
"timeout":10000,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url":"http://127.0.0.1:4744/wd/hub",
"maxSession": 4,
"port": 4744,
"host": "127.0.0.1",
"register": true,
"registerCycle": 5000,
"hubPort": 4444,
"hubHost": "127.0.0.1",
"role":"node"
}
}
{
"capabilities":
[
{
"browserName": "ANDROID",
"version":"4.3",
"maxInstances": 1,
"platform":"ANDROID"
}
],
"configuration":
{
"cleanUpCycle":2000,
"timeout":10000,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url":"http://127.0.0.1:4780/wd/hub",
"maxSession": 4,
"port": 4780,
"host": "127.0.0.1",
"register": true,
"registerCycle": 5000,
"hubPort": 4444,
"hubHost": "127.0.0.1",
"role":"node"
}
}
testng xml is as follows:
<?xml version="1.0" encoding="UTF-8"?>
thread-count="2">
<test name="ParallelExecution01" preserve-order="true">
<!-- <parameter name="DeviceId" value="ZX1D64QFK6"/> -->
<classes>
<class name="com.naukri.androidApp.TestSuite.ParallelExecution01">
<methods>
<include name="TC_01" />
</methods>
</class>
</classes>
</test>
<test name="ParallelExecution02" preserve-order="true">
<!-- <parameter name="DeviceId" value="a18dd209"/> -->
<classes>
<class name="com.naukri.androidApp.TestSuite.ParallelExecution01">
<methods>
<include name="TC_02" />
</methods>
</class>
</classes>
</test>
When I'm executing this code, it launches app only on any one device at a device. And throws a nullPointerException at "driver01 = new AndroidDriver(new URL("http://127.0.0.1:4444/wd/hub"), capabilities);" for both cases.
[TestNG] Running:
[ThreadUtil] Starting executor timeOut:2147483647ms workers:1 threadPoolSize:2
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
[Status]:TC_01_FAIL
[End]:08_51_30PM_10_Oct_2015_IP14.98.195.87
[Snapshot]:Click Here
[Status]:TC_02_FAIL
[End]:08_51_50PM_10_Oct_2015_IP14.98.195.87
[Snapshot]:Click Here
FAILED: TC_01
java.lang.NullPointerException
at com.naukri.androidApp.TestSuite.ParallelExecution01.StartDriverAndroidApp01(ParallelExecution01.java:86)
at com.naukri.androidApp.TestSuite.ParallelExecution01.StartDriver01(ParallelExecution01.java:42)
at com.naukri.androidApp.TestSuite.ParallelExecution01.TC_01(ParallelExecution01.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.access$000(SuiteRunner.java:37)
at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:368)
at org.testng.internal.thread.ThreadUtil$2.call(ThreadUtil.java:64)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
FAILED: TC_02
java.lang.NullPointerException
at com.naukri.androidApp.TestSuite.ParallelExecution01.StartDriverAndroidApp02(ParallelExecution01.java:141)
at com.naukri.androidApp.TestSuite.ParallelExecution01.StartDriver02(ParallelExecution01.java:108)
at com.naukri.androidApp.TestSuite.ParallelExecution01.TC_02(ParallelExecution01.java:166)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.access$000(SuiteRunner.java:37)
at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:368)
at org.testng.internal.thread.ThreadUtil$2.call(ThreadUtil.java:64)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
===============================================
Default test
Tests run: 2, Failures: 2, Skips: 0
===============================================
===============================================
androidautomationnaukriindia
Total tests run: 2, Failures: 2, Skips: 0
===============================================
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@4a2c1b1c: 8 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 9 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@4f8d0299: 10 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@309e7e21: 59 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@195bd6b9: 14 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@25b5dab5: 37 ms
@rashiatry
Make sure of the following:
- You have started Appium servers with the correct IP addresses and port numbers on the nodes.
- You need to provide the UDID of the device
- Please provide Appium logs
- Please provide hub log
@rashiatry :- When you use two driver instances for each devices means you are executing two different tests. It may run parallel but I think its not a good idea to develop your tests, because now tomorrow if you want to run test on 3 or 4 devices then again you need to create driver2 and driver3. I don't think its a good solution for long run. I have a solution with single driver instance (for more details send a mail to appiummaster@gmail.com).
Refer this video
