appium / dotnet-client

Extension to the official Selenium dotnet webdriver
Apache License 2.0
381 stars 187 forks source link

AutomationName produces error ("cant be blank" although it is not blank) #603

Closed DanaT1234 closed 1 year ago

DanaT1234 commented 1 year ago

Is there an existing issue for this? I have searched the existing issues

Current Behavior Although an AutomationName is specified, an Error ("OpenQA.Selenium.WebDriverArgumentException: 'automationName' can't be blank") appears when trying to initialize the AppiumDriver

Expected Behavior I expect no errors

Minimal Reproducible Example

  1. start appium server

  2. Try to initialize AndroidDriver with c# code:

        AppiumOptions capabilities = new AppiumOptions();
        capabilities.AddAdditionalAppiumOption("AutomationName", "UiAutomator2");
        capabilities.AddAdditionalAppiumOption("DeviceName", "Samsung-A52-01");
        capabilities.AddAdditionalAppiumOption("platformName", "Android");
        capabilities.AddAdditionalAppiumOption("browserName", "chrome");
        capabilities.AddAdditionalAppiumOption("PlatformVersion", "12");
        AppiumDriver driver = new AndroidDriver(new Uri("http://localhost:4723"), capabilities, TimeSpan.FromMilliseconds(60000));
  3. see Error

Environment Operating system: Windows 10 Appium: 2.0.0-beta.64 Appium.Webdriver: 5.0.0-beta03 Platform and version under test: Android 12 Real device or emulator/simulator: Real device

Appium Logs

[Appium] Appium REST http interface listener started on 0.0.0.0:4723 [Appium] Available drivers: [Appium] - uiautomator2@2.15.0 (automationName 'UiAutomator2') [Appium] No plugins have been installed. Use the "appium plugin" command to install the one(s) you want to use. [debug] [HTTP] Request idempotency key: efca2972-c2a9-48a5-b95d-cfc7d7ea2b9c [HTTP] --> POST /session [HTTP] {"capabilities":{"firstMatch":[{"platformName":"Android","appium:AutomationName":"UiAutomator2","appium:DeviceName":"Samsung-A52-01","appium:platformName":"Android","appium:browserName":"chrome","appium:PlatformVersion":"12"}]}} [debug] [AppiumDriver@9e0f] Calling AppiumDriver.createSession() with args: [null,null,{"firstMatch":[{"platformName":"Android","appium:AutomationName":"UiAutomator2","appium:DeviceName":"Samsung-A52-01","appium:platformName":"Android","appium:browserName":"chrome","appium:PlatformVersion":"12"}]}] [debug] [AppiumDriver@9e0f] Event 'newSessionRequested' logged at 1681829711784 (16:55:11 GMT+0200 (Central European Summer Time)) [BaseDriver] Ignoring capability 'appium:platformName=Android' and using capability 'platformName=Android' [BaseDriver] The capabilities ["platformName","browserName"] are standard capabilities and do not require "appium:" prefix [Appium] Could not parse W3C capabilities: 'automationName' can't be blank [debug] [AppiumDriver@9e0f] Event 'newSessionStarted' logged at 1681829711790 (16:55:11 GMT+0200 (Central European Summer Time)) [debug] [AppiumDriver@9e0f] Encountered internal error running command: InvalidArgumentError: 'automationName' can't be blank [debug] [AppiumDriver@9e0f] at processCapabilities (C:\Users\username.nvm\node_modules\appium\node_modules\@appium\base-driver\lib\basedriver\capabilities.js:345:13) [debug] [AppiumDriver@9e0f] at parseCapsForInnerDriver (C:\Users\username.nvm\node_modules\appium\lib\utils.js:135:40) [debug] [AppiumDriver@9e0f] at AppiumDriver.createSession (C:\Users\username.nvm\node_modules\appium\lib\appium.js:251:49) [debug] [AppiumDriver@9e0f] at commandExecutor (C:\Users\username.nvm\node_modules\appium\node_modules\@appium\base-driver\lib\basedriver\driver.ts:106:18) [debug] [AppiumDriver@9e0f] at AppiumDriver.executeCommand (C:\Users\username.nvm\node_modules\appium\node_modules\@appium\base-driver\lib\basedriver\driver.ts:123:15) [debug] [AppiumDriver@9e0f] at processTicksAndRejections (node:internal/process/task_queues:96:5) [debug] [AppiumDriver@9e0f] at defaultBehavior (C:\Users\username.nvm\node_modules\appium\lib\appium.js:680:16) [debug] [AppiumDriver@9e0f] at AppiumDriver.executeWrappedCommand (C:\Users\username.nvm\node_modules\appium\lib\appium.js:774:16) [debug] [AppiumDriver@9e0f] at AppiumDriver.executeCommand (C:\Users\username.nvm\node_modules\appium\lib\appium.js:696:17) [debug] [AppiumDriver@9e0f] at asyncHandler (C:\Users\username.nvm\node_modules\appium\node_modules\@appium\base-driver\lib\protocol\protocol.js:387:19) [HTTP] <-- POST /session 400 52 ms - 1521

Futher Information Others seem to have encountered the same issue: https://discuss.appium.io/t/appium-2-with-c/38680/10

mykola-mokhnach commented 1 year ago

The error is valid. Capability names are case-sensitive, so

"AutomationName" -> "UiAutomator2"

is not recognised as valid cap

DanaT1234 commented 1 year ago

What should it be instead? "UiAutomator2" is exactly the name that is stated by the Appium Logs. I'm new to Appium, maybe you can clarify what the name should be instead?

DanaT1234 commented 1 year ago

Or are you refering to "AutomationName" starting with "A" in my code but with "a" in the Error? I've already tried writing "automationName" instead, but that gets another Error ("System.ArgumentException: There is already an option for the appium:automationName capability. Please use the AutomationName property instead."), so i thought it had to be "AutomationName" and not "automationName"

laolubenson commented 1 year ago

@DanaT1234 have you tried the suggestion provided by the error message, and setting the AutomationName property to UiAutomator2? i.e,capabilities.AutomationName = "UiAutomator2";

Dor-bl commented 1 year ago

AutomationName is already defined as part of the appium options. Just use 'appiumOptions.AutomationName' instead of calling the add additional options method

DanaT1234 commented 1 year ago

@laolubenson Thank You! It seems like i have misunderstood the error message. It seems to work now