Skip to content

Could not start ATD test with android because of Illegal key values seen in w3c capabilities: [automationName] #1222

@hungdao-testing

Description

@hungdao-testing

Hi ,

I am facing issue that could not run ATD (distribute mode) for Android platform (for iOS, it's working). Here is my setup

Setup

RUNNER=distribute
FRAMEWORK=testng
LISTENERS=common.testng.MobileTestNgCustomAtdListener
MAX_RETRY_COUNT=2

APPIUM_JS_PATH=/Users/.nvm/versions/node/v20.13.1/lib/node_modules/appium/build/lib

## Default path to capability json is root/caps/capabilities.json if the location of the capabilities.json is changed make sure you mention as below
CAPS=./src/test/resources/mobile/caps/capabilities.json
SUITE_NAME=formcli-atd
APP_TYPE=NA
{
  "android": {
    "appium:platformName": "Android",
    "automationName": "UiAutomator2",
    "appium:newCommandTimeout": 300,
    "appium:noReset": false,
    "appium:app": "./src/test/resources/mobile/apps/formscli_android.apk",
    "appium:maxTypingFrequency": 30,
    "appium:deviceName": "android"
  },

  "iOS": {
  },
  "ios": {
    "appium:platformName": "ios",
    "appium:app": "./src/test/resources/mobile/apps/formscli_ios.zip",
    "appium:automationName": "XCUITest",
    "appium:newCommandTimeout": 300,
    "appium:noReset": false,
    "appium:maxTypingFrequency": 30,
    "df:udids": "A16F7F75-FBE3-4C01-8E69-FFDDC5B4A585, CAAB1A78-3B85-4B84-B35C-702A21D330C3",
    "appium:wdaLaunchTimeout": 80000,
    "appium:wdaConnectionTimeout": 80000,
    "appium:preventWDAAttachments": true,
    "appium:usePrebuiltWDA": true,
    "appium:clearSystemFiles": true,
    "appium:shouldUseSingletonTestManager": false,
    "appium:simpleIsVisibleCheck": true
  },
  "serverConfig": {
    "server": {
      "port": 31337,
      "use-plugins": [
        "device-farm",
        "element-wait"
      ],
      "plugin": {
        "device-farm": {
          "platform": "android",
          "skipChromeDownload": true,
          "iosDeviceType": "both",
          "androidDeviceType": "both",
          "maxSessions": 2
        }
      }
    }
  },
  "basePath": ""
}

Already installed : device-farm plugin as latest version in local machine and AppiumTestDistribution in pom file

<dependency>
            <groupId>io.appium</groupId>
            <artifactId>java-client</artifactId>
            <version>9.4.0</version>
        </dependency>

<dependency>
            <groupId>com.github.saikrishna321</groupId>
            <artifactId>AppiumTestDistribution</artifactId>
            <version>14.0.4</version>
        </dependency>
    </dependencies>

Runner class

public class Runner {
    @Test
    public void testApp() throws Exception {
        ATDRunner parallelThread = new ATDRunner();
        List<String> tests = new ArrayList<>();
        tests.add("HomeScreenTest");

        boolean runner = parallelThread.runner("auto.mobile.formcliatd.specs", tests);
        Assert.assertFalse(runner);
    }
}

Execution

Run directly Runner class via Intelij with property -Dplatform=android

Errors

Capture in file test.log

14:05:47.812 [main] INFO  com.appium.utils.ConfigFileManager - Using config file from [./configs/config.properties]
14:05:47.840 [main] INFO  com.appium.manager.AppiumServerManager - com.appium.manager.AppiumServerManagerStarting Appium Server on Localhost
14:05:47.840 [main] INFO  com.appium.manager.AppiumServerManager - Picking Default Path for AppiumServiceBuilder
14:05:47.844 [main] INFO  com.appium.manager.AppiumServerManager - Picking UserSpecified Base Path
14:05:50.586 [main] INFO  com.appium.manager.AppiumServerManager - com.appium.manager.AppiumServerManagerAppium Server Started at......http://127.0.0.1:31131/
14:05:50.828 [main] INFO  com.appium.utils.FigletHelper -       _   _         _            _   _               _          
   __| | (_)  ___  | |_   _ __  (_) | |__    _   _  | |_    ___ 
  / _` | | | / __| | __| | '__| | | | '_ \  | | | | | __|  / _ \
 | (_| | | | \__ \ | |_  | |    | | | |_) | | |_| | | |_  |  __/
  \__,_| |_| |___/  \__| |_|    |_| |_.__/   \__,_|  \__|  \___|
                                                                

14:05:50.828 [main] INFO  com.appium.manager.ATDRunner - com.appium.manager.ATDRunnerTotal Number of devices detected::1

14:05:50.896 [main] INFO  com.appium.utils.Helpers - Custom Listener not found!!
14:05:50.922 [TestNG-test-ATDTest-1] INFO  com.appium.capabilities.DesiredCapabilityBuilder - Capabilities file is not specified. Using default capabilities file
14:05:50.922 [TestNG-test-ATDTest-1] INFO  com.appium.manager.AppiumDriverManager - startAppiumDriverInstance for setUpHomeScreen using capability file: ./src/test/resources/mobile/caps/capabilities.json
14:05:50.922 [TestNG-test-ATDTest-1] INFO  com.appium.manager.AppiumDriverManager - startAppiumDriverInstance
14:05:50.923 [TestNG-test-ATDTest-1] INFO  com.appium.manager.AppiumDriverManager - Initialise Driver with Capabilities: 
	appium:app:: src/test/resources/mobile/apps/formscli_android.apk
	appium:deviceName:: android
	appium:maxTypingFrequency:: 30
	appium:newCommandTimeout:: 300
	appium:noReset:: false
	appium:platformName:: Android
	automationName:: UiAutomator2
14:05:51.044 [TestNG-test-ATDTest-1] INFO  com.appium.manager.AppiumParallelMethodTestListener - Driver Session exisstsfalsenull
14:05:51.046 [TestNG-test-ATDTest-1] INFO  com.context.SessionContext - SessionContext default constructor
14:05:51.046 [TestNG-test-ATDTest-1] INFO  com.context.SessionContext - Using reportportal.properties file from src/test/resources/reportportal.properties
14:05:51.046 [TestNG-test-ATDTest-1] INFO  com.context.SessionContext - reportportal.properties file NOT FOUND - /Users/hungminh/hung/programming/automation/java-appium-formclis/src/test/resources/reportportal.properties
14:05:51.046 [TestNG-test-ATDTest-1] INFO  com.context.SessionContext - Initialized SessionContext
14:05:51.047 [TestNG-test-ATDTest-1] INFO  com.context.SessionContext - Removing context for thread - 22
14:05:51.106 [TestNG-test-ATDTest-1] INFO  common.testng.MobileTestNgCustomAtdListener - Test Started: testUserCouldGoToCheckoutScreen
14:05:51.106 [TestNG-test-ATDTest-1] INFO  com.appium.capabilities.DesiredCapabilityBuilder - Capabilities file is not specified. Using default capabilities file
14:05:51.106 [TestNG-test-ATDTest-1] INFO  com.appium.manager.AppiumDriverManager - startAppiumDriverInstance for testUserCouldGoToCheckoutScreen using capability file: ./src/test/resources/mobile/caps/capabilities.json
14:05:51.106 [TestNG-test-ATDTest-1] INFO  com.appium.manager.AppiumDriverManager - startAppiumDriverInstance
14:05:51.107 [TestNG-test-ATDTest-1] INFO  com.appium.manager.AppiumDriverManager - Initialise Driver with Capabilities: 
	appium:app:: src/test/resources/mobile/apps/formscli_android.apk
	appium:deviceName:: android
	appium:maxTypingFrequency:: 30
	appium:newCommandTimeout:: 300
	appium:noReset:: false
	appium:platformName:: Android
	automationName:: UiAutomator2
14:05:51.109 [TestNG-test-ATDTest-1] INFO  com.appium.manager.AppiumParallelMethodTestListener - Driver Session exisstsfalsenull
14:05:51.109 [TestNG-test-ATDTest-1] INFO  com.context.SessionContext - Removing context for thread - 22
14:05:51.120 [main] INFO  com.appium.manager.AppiumServerManager - Shutting down Appium Server
14:05:51.154 [main] INFO  com.appium.utils.FigletHelper -   _____                _        ____                               _          _                _ 
 |_   _|   ___   ___  | |_     / ___|   ___    _ __ ___    _ __   | |   ___  | |_    ___    __| |
   | |    / _ \ / __| | __|   | |      / _ \  | '_ ` _ \  | '_ \  | |  / _ \ | __|  / _ \  / _` |
   | |   |  __/ \__ \ | |_    | |___  | (_) | | | | | | | | |_) | | | |  __/ | |_  |  __/ | (_| |
   |_|    \___| |___/  \__|    \____|  \___/  |_| |_| |_| | .__/  |_|  \___|  \__|  \___|  \__,_|
                                                          |_|                                    

Throw in console

org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. 
Host info: host: 'MacBook-Pro.local', ip: 'fe80:0:0:0:10bb:2c6d:a479:7d86%en0'
Build info: version: '4.32.0', revision: 'd17c8aa950'
System info: os.name: 'Mac OS X', os.arch: 'aarch64', os.version: '14.5', java.version: '17.0.14'
Driver info: io.appium.java_client.android.AndroidDriver
Command: [null, newSession {capabilities=[Capabilities {appium:app: src/test/resources/mobile/a..., appium:deviceName: android, appium:maxTypingFrequency: 30, appium:newCommandTimeout: 300, appium:noReset: false, appium:platformName: Android, automationName: UiAutomator2, platformName: ANDROID}]}]
Capabilities {appium:app: src/test/resources/mobile/a..., appium:deviceName: android, appium:maxTypingFrequency: 30, appium:newCommandTimeout: 300, appium:noReset: false, appium:platformName: Android, automationName: UiAutomator2, platformName: ANDROID}
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:563)
	at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:313)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:174)
	at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:101)
	at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:113)
	at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:109)
	at com.appium.manager.AppiumDriverManager.createAppiumDriver(AppiumDriverManager.java:66)
	at com.appium.manager.AppiumDriverManager.initialiseDriver(AppiumDriverManager.java:52)
	at com.appium.manager.AppiumDriverManager.startAppiumDriverInstance(AppiumDriverManager.java:104)
	at com.appium.manager.AppiumDriverManager.startAppiumDriverInstance(AppiumDriverManager.java:89)
	at com.appium.manager.AppiumParallelMethodTestListener.allocateDeviceAndStartDriver(AppiumParallelMethodTestListener.java:101)
	at com.appium.manager.AppiumParallelMethodTestListener.beforeInvocation(AppiumParallelMethodTestListener.java:74)
	at org.testng.internal.invokers.InvokedMethodListenerInvoker.invokeListener(InvokedMethodListenerInvoker.java:55)
	at org.testng.internal.invokers.BaseInvoker.runInvokedMethodListeners(BaseInvoker.java:82)
	at org.testng.internal.invokers.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:370)
	at org.testng.internal.invokers.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:333)
	at org.testng.internal.invokers.TestInvoker.runConfigMethods(TestInvoker.java:833)
	at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:600)
	at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:230)
	at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:63)
	at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:992)
	at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:203)
	at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:154)
	at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:134)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.testng.internal.thread.graph.TestNGFutureTask.run(TestNGFutureTask.java:22)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.IllegalArgumentException: Illegal key values seen in w3c capabilities: [automationName]
	at org.openqa.selenium.remote.NewSessionPayload.lambda$validate$5(NewSessionPayload.java:163)
	at java.base/java.util.stream.ReferencePipeline$15$1.accept(ReferencePipeline.java:540)
	at java.base/java.util.stream.ReferencePipeline$15$1.accept(ReferencePipeline.java:541)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.ReferencePipeline$15$1.accept(ReferencePipeline.java:541)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at org.openqa.selenium.remote.NewSessionPayload.validate(NewSessionPayload.java:167)
	at org.openqa.selenium.remote.NewSessionPayload.<init>(NewSessionPayload.java:70)
	at org.openqa.selenium.remote.NewSessionPayload.create(NewSessionPayload.java:99)
	at org.openqa.selenium.remote.NewSessionPayload.create(NewSessionPayload.java:84)
	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:60)
	at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:178)
	at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:243)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
	... 29 more

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions