Not able to run test in multiple devices by keeping automationName -> uiautomator2

I automated selenium grid for appium expecting to run multiple test in parallel.
Once i was done with the code i started testing it.

I started by passing some sample test blocks with few Xpaths of apps present in playstore. But i hit a wall now.

When i set automationName as Appium both the device executes test parallel .

capabilities.setCapability("automationName","Appium");

but its not able to find the xpath mentioned below.

Xpath //androidx.appcompat.app.ActionBar.Tab[@index=0]

Same if i change automationName to uiautomator2 the above mentioned element is found.

capabilities.setCapability(“automationName”,“uiautomator2”);

But when the second device tries to start execution unknow server exception is throwed.

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to remote server. Original error: Error: socket hang up

I’m not able to make any progress. I been testing few things out.
but its a waste of time.

If anyone has gone through this before please help me out.
even suggestions are welcome.

Thanks

1 Like

@mykola-mokhnach i have set udid capability and also assigned different system ports for appium nodes.

Below is the grid config

When i set capability automationName to uiautomator2 then only second node is not functioning same i tried with Appium it works but the end its having problems to find Xpaths which uiautomator2 is able to do.

Exception:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to remote server. Original error: Error: connect ECONNREFUSED 127.0.0.1:8200
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:48’
System info: host: ‘LT0018432’, ip: ‘10.89.196.115’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘10.0.2’
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities {appActivity: .main.splashscreen.SplashSc…, appPackage: com.jio.web, automationName: UiAutomator2, databaseEnabled: false, desired: {appActivity: .main.splashscreen.SplashSc…, appPackage: com.jio.web, automationName: UiAutomator2, deviceName: 330059b08fd323db, platformName: android, platformVersion: 7.0, udid: 330059b08fd323db}, deviceApiLevel: 24, deviceManufacturer: samsung, deviceModel: SM-A510F, deviceName: 330059b08fd323db, deviceScreenDensity: 480, deviceScreenSize: 1080x1920, deviceUDID: 330059b08fd323db, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, pixelRatio: 3, platform: LINUX, platformName: Android, platformVersion: 7.0, statBarHeight: 72, takesScreenshot: true, udid: 330059b08fd323db, viewportRect: {height: 1848, left: 0, top: 72, width: 1080}, warnings: {}, webStorageEnabled: false}
Session ID: bff16013-a90d-4213-95ae-86cfe32da518
*** Element info: {Using=xpath, value=//android.widget.TextView[@text=‘SKIP’]}
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:231)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:62)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:428)
at io.appium.java_client.DefaultGenericMobileDriver.findElementByXPath(DefaultGenericMobileDriver.java:152)
at io.appium.java_client.AppiumDriver.findElementByXPath(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElementByXPath(AndroidDriver.java:1)
at org.openqa.selenium.By$ByXPath.findElement(By.java:353)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:58)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:205)
at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:201)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:249)
at com.au.test.SampleTestClass.sampleTest(SampleTestClass.java:26)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:580)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:716)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:988)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:648)
at org.testng.TestRunner.run(TestRunner.java:505)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
at org.testng.SuiteRunner.access$000(SuiteRunner.java:40)
at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:489)
at org.testng.internal.thread.ThreadUtil$1.call(ThreadUtil.java:52)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:844)

I cross checked most of the things i’m not able to understand whats causing the issue.

Full Log: (Execution & Node stream buffer)
ExecutionLog.log (201.1 KB)

How to pass default capabilities in new appium version like how he has done below.

I dont see a flag like that now.
usage:
[-h] [-v] [–shell] [–allow-cors] [–reboot] [–ipa IPA] [-a ADDRESS]
[-p PORT] [-ca CALLBACKADDRESS] [-cp CALLBACKPORT] [-bp BOOTSTRAPPORT]
[-r BACKENDRETRIES] [–session-override] [-l] [-g LOGFILE]
[–log-level {info,info:debug,info:info,info:warn,info:error,warn,warn:debug,warn:info,warn:warn,warn:error,error,error:debug,error:info,error:warn,error:error,debug,debug:debug,debug:info,debug:warn,debug:error}]
[–log-timestamp] [–local-timezone] [–log-no-colors] [-G WEBHOOK]
[–safari] [–default-device] [–force-iphone] [–force-ipad]
[–tracetemplate AUTOMATIONTRACETEMPLATEPATH]
[–instruments INSTRUMENTSPATH] [–nodeconfig NODECONFIG]
[-ra ROBOTADDRESS] [-rp ROBOTPORT] [–selendroid-port SELENDROIDPORT]
[–chromedriver-port CHROMEDRIVERPORT]
[–chromedriver-executable CHROMEDRIVEREXECUTABLE] [–show-config]
[–no-perms-check] [–strict-caps] [–isolate-sim-device]
[–tmp TMPDIR] [–trace-dir TRACEDIR] [–debug-log-spacing]
[–suppress-adb-kill-server] [–long-stacktrace]
[–webkit-debug-proxy-port WEBKITDEBUGPROXYPORT]
[–webdriveragent-port WDALOCALPORT] [-dc DEFAULTCAPABILITIES]
[–enable-heapdump] [–relaxed-security]
[–command-timeout DEFAULTCOMMANDTIMEOUT] [-k]
[–platform-name PLATFORMNAME] [–platform-version PLATFORMVERSION]
[–automation-name AUTOMATIONNAME] [–device-name DEVICENAME]
[–browser-name BROWSERNAME] [–app APP] [-lt LAUNCHTIMEOUT]
[–language LANGUAGE] [–locale LOCALE] [-U UDID]
[–orientation ORIENTATION] [–no-reset] [–full-reset]
[–app-pkg APPPACKAGE] [–app-activity APPACTIVITY]
[–app-wait-package APPWAITPACKAGE]
[–app-wait-activity APPWAITACTIVITY]
[–device-ready-timeout DEVICEREADYTIMEOUT]
[–android-coverage ANDROIDCOVERAGE] [–avd AVD] [–avd-args AVDARGS]
[–use-keystore] [–keystore-path KEYSTOREPATH]
[–keystore-password KEYSTOREPASSWORD] [–key-alias KEYALIAS]
[–key-password KEYPASSWORD] [–intent-action INTENTACTION]
[–intent-category INTENTCATEGORY] [–intent-flags INTENTFLAGS]
[–intent-args OPTIONALINTENTARGUMENTS] [–dont-stop-app-on-reset]
[–calendar-format CALENDARFORMAT] [–native-instruments-lib]
[–keep-keychains] [–localizable-strings-dir LOCALIZABLESTRINGSDIR]
[–show-ios-log] [–async-trace]

Thanks this was really helpful @mykola-mokhnach .
took a while to understand. Working fine now.

For those who face the same problem:
What you need to do is simple.
set desired capabilities like this when you create driver
capabilities.setCapability(“systemPort”,systemPort);
along with other capabilities.

so the next problem you will face is same error because its going to use same port for multiple devices…
Every driver needs a unique port between 8200 to 8299
So to do that
add a parameter in testng.xml like this
<parameter name=“systemPort” value=“8201”/>

and pass it to
@BeforeTest(alwaysRun = true)
@Parameters({ “port”, “device”, “platformVersion”, “systemIp”, “systemPort” })

thats all.

I’m done making my changes. Below mentioned repository is having code
which will automatically configure appium nodes, selenium grid and start execution for devices connected to PC.

https://github.com/AutomatorsSidekick/Appium-AutoGrid.git

Those who are trying to configure parallel tests can use.
It will sure save sometime.

Hello @Prajith_KP

Could you please help with the complete code ?

Need to know what is written in Capability class, Testcase file and Testng .

I am doing the same but facing issue with passing the values