Luck didn't favour for ios parallel execution with appium 1.5.3

I have been going through lots of forums and found mixed comments saying that parallel execution of ios devices with appium is possible/impossible…but luck didn’t favour as I followed all the steps provided by @saikrishna and @SrinivasanTarget but unable to succeed for not even a single instance…I am trying to execute iphone 5s(8.2) and iPad Pro(9.3.2) parallelly using appium but nothing didn’t work

Environment

Appium 1.5.3
Max OS X 10.11.6
iphone 5s(8.2) and iPad Pro(9.3.2)
Details

I am going to start Appium from terminal using the command node main.js -p 4727 -bp 5786 --nodeconfig iPhone5sConfig.json and node main.js -p 4726 -bp 5785 --nodeconfig iPadProConfig.json both start successfully and register to hub but script gets executed only in iPhone 5s and fail to start in iPad Pro besides getting exception as provided below…tried with different types of parts but no change…sometimes tried to connect iPhone 6 Plus but same exception…tried to change the config file and json file but no change in the result…I am desperate that parallel execution is not possible to me but hope full that @saikrishna and @SrinivasanTarget along with others could help me to achieve this activity successfully

Link to Appium logs

org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: ‘2.53.1’, revision: ‘a36b8b1’, time: ‘2016-06-30 17:32:46’
System info: host: ‘MyMachine’, ip: ‘MyMachineIPAddress’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.11.6’, java.version: ‘1.8.0_45’
Driver info: driver.version: IOSDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:40)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.ios.IOSDriver.execute(IOSDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:144)
at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:36)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:114)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:132)
at io.appium.java_client.ios.IOSDriver.(IOSDriver.java:82)
at com.mobienxV6_3.automation.execution.iOSDeviceExecution.driverCreation(iOSDeviceExecution.java:276)
at com.mobienxV6_3.automation.execution.iOSDeviceExecution.ExecutionMode(iOSDeviceExecution.java:107)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:515)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:216)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:143)
at org.testng.TestRunner.beforeRun(TestRunner.java:631)
at org.testng.TestRunner.run(TestRunner.java:599)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:368)
at org.testng.SuiteRunner.access$000(SuiteRunner.java:39)
at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:402)
at org.testng.internal.thread.ThreadUtil$2.call(ThreadUtil.java:64)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.openqa.selenium.WebDriverException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:4726 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused
Build info: version: ‘2.53.1’, revision: ‘a36b8b1’, time: ‘2016-06-30 17:32:46’
System info: host: ‘MyMachine’, ip: ‘MyIPAddress’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.11.6’, java.version: ‘1.8.0_45’
Driver info: driver.version: IOSDriver
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:84)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
… 30 more
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to localhost:4726 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:151)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:144)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:90)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:69)
… 31 more
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:74)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134)
… 44 more

Code To Reproduce Issue [ Good To Have ]

I have configured my TestNG file as shown below:-

And passing the parameters of this file as shown below:-
public RemoteWebDriver driver;
capa.setCapability ( MobileCapabilityType.UDID , udid );
capa.setCapability ( MobileCapabilityType.PLATFORM_NAME , “iOS” );
capa.setCapability ( MobileCapabilityType.PLATFORM_VERSION ,
iOSVersion );
capa.setCapability ( MobileCapabilityType.APP ,
app.getAbsolutePath ( ) );
capa.setCapability ( MobileCapabilityType.DEVICE_NAME , “=”

  • deviceName );
    capa.setCapability ( “bundleid” , IOSReferenceVairables.appbundleId );
    return ( IOSDriver < IOSElement > ) ( driver = new IOSDriver <> (
    new URL ( “http://localhost:” + port + “/wd/hub” ) , capa ) );
    script gets invoked successfully in iPhone 5s but fails both in iPad Pro and iPhone 6 Plus when connected them separately along with iPhone 5s…I searched all the issues from this and other forums but my success mile is not reached hence as final hope I write here and sorry if I could have not digged much into this forum…Also want to tell that when I checked in http://appium.io/slate/en/1.5.3/?ruby#parallel-ios-tests it is strongly telling that iOS parallel execution is possible only with Sauce Labs but didn’t understand how few people reached the success mile without this hence desperately I request to help me to get this issue solved
    JSON files
    iPad Pro Config JSON
    {
    “capabilities”: [
    {
    “browserName”: “iPad Pro”,
    “version”: “9.3.2”,
    “maxInstances”: 1,
    “tmp”: “/Users/MyMachine/temp2/”,
    “platform”: “MAC”
    }
    ],
    “configuration”: {
    “cleanUpCycle”: 2000,
    “timeout”: 300000,
    “proxy”: “org.openqa.grid.selenium.proxy.DefaultRemoteProxy”,
    “url”: “http://0.0.0.0:4726/wd/hub”,
    “host”: “0.0.0.0”,
    “port”: 4726,
    “maxSession”: 1,
    “register”: true,
    “registerCycle”: 5000,
    “hubPort”: 4444,
    “hubHost”: “localhost”
    }
    }

iPhone5sConfig.json
{
“capabilities”: [
{
“browserName”: “iPhone 5s”,
“version”: “8.2”,
“maxInstances”: 1,
“tmp”: “/Users/MyMachine/temp3/”,
“platform”: “MAC”
}
],
“configuration”: {
“cleanUpCycle”: 2000,
“timeout”: 300000,
“proxy”: “org.openqa.grid.selenium.proxy.DefaultRemoteProxy”,
“url”: “http://0.0.0.0:4727/wd/hub”,
“host”: “0.0.0.0”,
“port”: 4727,
“maxSession”: 1,
“register”: true,
“registerCycle”: 5000,
“hubPort”: 4444,
“hubHost”: “localhost”
}
}

iPhone6PlusConfig.json
{
“capabilities”: [
{
“deviceName”: “iPhone 6 Plus”,
“version”: “8.3”,
“maxInstances”: 5,
“tmp”: “/Users/MyMachine/temp1/”,
“platform”: "MAC,

}

],
“configuration”: {
“cleanUpCycle”: 2000,
“timeout”: 300000,
“proxy”: “org.openqa.grid.selenium.proxy.DefaultRemoteProxy”,
“url”: “http://0.0.0.0:4737/wd/hub”,
“host”: “0.0.0.0”,
“port”: 4737,
“maxSession”: 1,
“register”: true,
“registerCycle”: 5000,
“hubPort”: 4444,
“hubHost”: “localhost”
}
}

  1. why don’t you use appim.js? for 1.5.3 you can use appim instead.
  2. try to add additionl flag to your command: --tmp /tmp/some-uniqe-file-name

Hope it will help you
Eitan.

As per my personal experience and suggestion from lots of forums appium.js will not work to invoke appium from 1.5.3 version hence using main.js

What do you mean in saying “not work”? The server doesn’t start? which problem it can caouse?
I use appium, the server starting without any issue.
The only thing that i MUST understand it way i gets SessionNotFoundException after 30 minutes. (after 20 scenarios)

For me appium server starts successfully along with the Selenium Grid and node successfully registering the hub but creation of session is happening in only 1 device when 2 devices are connected. As already shared logs signify the connection is refused with HttpException with all the steps followed. But I have few questions here…

  1. Just now I tried the steps provided by @saikrishna321 for starting Appium server programatically and following the order of sending the parameters to the class AppiumDriverLocalService for creating the Appium service which made me successfully starting my script in all 3 devices (2 iphones and 1 iPad) connected to single Mac machine successfully hence I am so thankful to @saikrishna321 ---- for sharing the knowledge of starting starting Appium programatically for parallel execution and Aswini Kumar Sahu from his blog http://aksahu.blogspot.in/2015/10/start-and-stop-appium-server.html for creating the foundation in starting Appium server programatically. In one of the forums I came to know that irrespective of platform (iOS/Android) udid is mandatory for parallel execution if not provided then session will be started in the device which is ready and might not start in others hence followed the steps of SaiKrishna and A.K.Sahu I am able to do parallel execution for 3 ios devices in one machine with one instance of driver…but why the same is not happening when trying to use Selenium Grid…previously I used Selenium Grid for starting Hub and registering nodes. Hub starting, nodes registration and Appium server starting is successful but session created only in one device…why this has happened…is there any limitation with 1.5.3 with Selenium Grid…? Do we need to use always AppiumDriverLocalService for doing parallel execution…?
  2. Initially I am unable to get the value of udid using AppiumDriverLocalService class and when asked the same question I have not been provided any satisfied answer that made me successful…in one of the blog I came to know that from 1.5.3 ROBOT_ADDRESS can be used to access udid…eventhough the description doesn’t tell about this I tried to utilize this feature and reached the success mile of ios parallel execution with Appium. Hence I suggest someone who ever planning to do iOS parallel execution with Appium for the subsequent versions of 1.5.3 better use AppiumDriverLocalService alone with no Selenium Grid and nodes registration…we have lots of blogs and information from SaiKrishna and A.K.Sahu along with others too…