Appium – Parallel Execution (Grid) on iOS Real Devices using Single Mac Machine

Hi Friends,

I wrote an article on Appium – Parallel Execution (Grid) on iOS Real Devices using Single Mac Machine in my blog(https://appiumforbeginners.wordpress.com/appium-for-mac/)

Hope it’s useful for you out there :slight_smile:

1 Like

Thank you so much bro.
I could run testing parallel with 5 devices but couldn’t for iOS. I’ll give a try on your solution.

Thank again for your time to write it down!

Hi bro,

Why there was no “–webkit-debug-proxy-port”. How can appium server communicate with ios_webkit_debug_proxy?

I tried your steps provided in your blog but unable to execute in both the devices…I sent you a reply in the same blog about the issue I have been facing but no reply…can you please help me why I am unable to achieve but you can do it…am I not achieving something below are the details:-

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

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”
}
}

For the server command missing --tmp flag.
For example: –tmp “/Users/QABPA/Downloads/Grid/Device_iPod”

I followed your steps and modified the command as below:-
For Starting iPhone 5s
node main.js -p 4727 -bp 4730 --nodeconfig /Users/MyMachine/Documents/TestData/Parallel_Execution/iPhone5sConfig.json --tmp /Users/MyMachine/tmp/temp3/
For Starting iPhone 6 Plus
node main.js -p 4728 -bp 4731 --nodeconfig /Users/MyMachine/Documents/TestData/Parallel_Execution/iPhone6PlusConfig.json --tmp /Users/MyMachine/tmp/temp1/

the result is same and there is no change…while opening the temp folders I found the temp folder for iPhone 5s which is executing successfully is not empty and has a folder with name appium-instruments which has some content…to differentiate between the instrument I am giving the below line for creating the capabilities as:-

if (deviceName.contains ( “iPhone” )) {
capa = DesiredCapabilities.iphone ( );
System.out.println ( “CREATING DRIVER FOR IPHONE” );
driver = driverCreation ( capa , deviceName , iOSVersion ,
port , udid , app );
}
if (deviceName.contains ( “iPad” )) {
capa = DesiredCapabilities.ipad ( );
System.out.println ( “CREATING DRIVER FOR IPAD” );
driver = driverCreation ( capa , deviceName , iOSVersion ,
port , udid , app );
I am creating the driver instance in a separate method because when I check the terminal for appium logs I can see the desired capabilities displayed for iPhone5s at HTTP but the same is blank for iPhone 6 Plus…I feel once the desired capabilities are pulled by iPhone 6 plus too session will be created in both devices hence result in parallel execution but this is not at all happening…experts please help me…

Sorry guy’s above solution is no more a valid Approach