Appium 2 with C#

Hi All,

I am trying to run Appium2 server with C# code but getting below mentioned error

Software versions:
Appium Server version: [email protected]
Appium Client: Appium.Webdriver-5.0.0/beta03
.Net version : 6.0

Error:
OpenQA.Selenium.WebDriverArgumentException : ‘automationName’ can’t be blank
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.
at OpenQA.Selenium.WebDriver.UnpackAndThrowOnError(Response errorResponse, String commandToExecute)
at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary2 parameters) at OpenQA.Selenium.Appium.AppiumDriver.Execute(String driverCommandToExecute, Dictionary2 parameters)
at OpenQA.Selenium.WebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.WebDriver…ctor(ICommandExecutor executor, ICapabilities capabilities)
at OpenQA.Selenium.Appium.AppiumDriver…ctor(ICommandExecutor commandExecutor, ICapabilities appiumOptions)

I am trying to set the capabilities as below:

Sample Code:
using System;
using System.Threading;
using Altom.AltUnityDriver;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Android;
using OpenQA.Selenium.Appium.Enums;
using OpenQA.Selenium.Appium.Interfaces;
using OpenQA.Selenium.Appium.iOS;
using OpenQA.Selenium.Support.UI;
public class Localtestrun{
[TestFixture]
public class Test
{
static IOSDriver appiumDriver;
static AltUnityDriver altUnityDriver;

    [SetUp]
    public void Setup()
    {
        var driverOptions = new AppiumOptions();

      string ipapath = @"/fiepath";
      string url = "http://127.0.0.1:4723/wd/hub";
      driverOptions.AddAdditionalAppiumOption("PlatformName","iOS");
      driverOptions.AddAdditionalAppiumOption("appium:AutomationName","XCUITest");
      driverOptions.AddAdditionalAppiumOption(MobileCapabilityType.Udid,"UDID");
      driverOptions.AddAdditionalAppiumOption("PlatformVersion","16.3.1");
      driverOptions.AddAdditionalAppiumOption("appium:App",ipapath);
      driverOptions.AddAdditionalAppiumOption("appium:DeviceName","iPhone 11");
      driverOptions.AddAdditionalAppiumOption(IOSMobileCapabilityType.AutoAcceptAlerts,"true");
     driverOptions.AddAdditionalAppiumOption(IOSMobileCapabilityType.AutoDismissAlerts,"true");

   
      appiumDriver = new IOSDriver(new Uri(url), driverOptions);
        System.Threading.Thread.Sleep(5000);
    }

}

Can you please help me understand what is going wrong here?

Post full log please. Would prefer it as a Git Gist.

capability names are case-sensitive, so the ‘automationName’ can’t be blank error above is totally expected.

1 Like

When i tried giving name as “appium:automationname” then i get an error as below:

"System.ArgumentException : There is already an option for the appium:automationName capability. Please use the AutomationName property instead. (Param…

System.ArgumentException : There is already an option for the appium:automationName capability. Please use the AutomationName property instead. (Parameter ‘capabilityName’)"

so use that property, what is the issue there?

So when i provide the name as mentioned in the ArgumentException than i am not able to connect the Server and get below mentioned error:

emphasized text [debug] [HTTP] Request idempotency key: 4c1cbf4b-4dcb-4ac8-aee7-1188e124778e

[HTTP] --> POST /wd/hub/session

[HTTP] {“capabilities”:{“firstMatch”:[{“platformName”:“Android”,“appium:platformName”:“Android”,“appium:AutomationName”:“UIAutomator2”,“appium:newCommandTimeout”:120,“appium:appPackage”:“com.lego.dad.legobuildinginstructions”,“appium:appActivity”:“com.unity3d.player.UnityPlayerActivity”,“appium:autoAcceptAlerts”:“true”,“appium:autoGrantPermissions”:“true”,“appium:App”:"/Users/username/Documents/BIAPP_NEW/Apps/Androidbuild/LEGOBuilder.apk"}]}}

[debug] [HTTP] No route found for /wd/hub/session

[HTTP] <-- POST /wd/hub/session 404 11 ms - 211

[HTTP]

[debug] [HTTP] Request idempotency key: 0a6b072d-8595-4833-8a1f-3e892b1f02b8

[HTTP] --> POST /wd/hub/session

[HTTP] {“capabilities”:{“firstMatch”:[{“platformName”:“Android”,“appium:platformName”:“Android”,“appium:AutomationName”:“UIAutomator2”,“appium:newCommandTimeout”:120,“appium:appPackage”:“com.lego.dad.legobuildinginstructions”,“appium:appActivity”:“com.unity3d.player.UnityPlayerActivity”,“appium:autoAcceptAlerts”:“true”,“appium:autoGrantPermissions”:“true”,“appium:App”:"/Users/usrname/Documents/BIAPP_NEW/Apps/Androidbuild/LEGOBuilder.apk"}]}}

[debug] [HTTP] No route found for /wd/hub/session

[HTTP] <-- POST /wd/hub/session 404 6 ms - 211

[HTTP]

[debug] [HTTP] Request idempotency key: ec7b680e-88b5-44cf-8991-5e06dadce114

[HTTP] --> POST /wd/hub/session

[HTTP] {“capabilities”:{“firstMatch”:[{“platformName”:“Android”,“appium:platformName”:“Android”,“appium:AutomationName”:“UIAutomator2”,“appium:newCommandTimeout”:120,“appium:appPackage”:“com.lego.dad.legobuildinginstructions”,“appium:appActivity”:“com.unity3d.player.UnityPlayerActivity”,“appium:autoAcceptAlerts”:“true”,“appium:autoGrantPermissions”:“true”,“appium:App”:"/Users/username/Documents/BIAPP_NEW/Apps/Androidbuild/LEGOBuilder.apk"}]}}

[debug] [HTTP] No route found for /wd/hub/session

[HTTP] <-- POST /wd/hub/session 404 1 ms - 211

[HTTP]

Can you try starting Appium server with –base-path=/wd/hub? Documentation:

I tried this option but no success: Still getting error;

OpenQA.Selenium.WebDriverArgumentException : ‘automationName’ can’t be blank
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.

Appium Server log:
[Appium] Welcome to Appium v2.0.0-beta.57 (REV 3fea5493a431ac64470d4230d4b51438cf213bd1)
[Appium] Non-default server args:
[Appium] {
[Appium] address: ‘127.0.0.1’,
[Appium] basePath: ‘/wd/hub’
[Appium] }
[Appium] Attempting to load driver xcuitest…
[debug] [Appium] Requiring driver at /Users/username/.appium/node_modules/appium-xcuitest-driver
[Appium] Attempting to load driver uiautomator2…
[debug] [Appium] Requiring driver at /Users/username/.appium/node_modules/appium-uiautomator2-driver
[Appium] Appium REST http interface listener started on 127.0.0.1:4723
[Appium] Available drivers:
[Appium] - [email protected] (automationName ‘XCUITest’)
[Appium] - [email protected] (automationName ‘UiAutomator2’)
[Appium] Available plugins:
[Appium] - [email protected]
[Appium] No plugins activated. Use the --use-plugins flag with names of plugins to activate
[debug] [HTTP] Request idempotency key: 5fd375af-3739-434b-bbce-4a47ef239a89
[HTTP] --> POST /wd/hub/session
[HTTP] {“capabilities”:{“firstMatch”:[{“platformName”:“Android”,“appium:platformName”:“Android”,“appium:AutomationName”:“UIAutomator2”,“appium:DeviceName”:“Galaxy S8”,“appium:newCommandTimeout”:0,“appium:PlatformVersion”:“8.0.0”,“appium:deviceId”:“ce0218221b50d63f01”,“appium:appPackage”:“com.lego.dad.legobuildinginstructions”,“appium:appActivity”:“com.unity3d.player.UnityPlayerActivity”,“appium:autoGrantPermissions”:“true”,“appium:App”:"/Users/usrname/Documents/BIAPP_NEW/Apps/Androidbuild/LEGOBuilder.apk"}]}}
[debug] [[email protected]] Calling AppiumDriver.createSession() with args: [null,null,{“firstMatch”:[{“platformName”:“Android”,“appium:platformName”:“Android”,“appium:AutomationName”:“UIAutomator2”,“appium:DeviceName”:“Galaxy S8”,“appium:newCommandTimeout”:0,“appium:PlatformVersion”:“8.0.0”,“appium:deviceId”:“ce0218221b50d63f01”,“appium:appPackage”:“com.lego.dad.legobuildinginstructions”,“appium:appActivity”:“com.unity3d.player.UnityPlayerActivity”,“appium:autoGrantPermissions”:“true”,“appium:App”:"/Users/usrname/Documents/BIAPP_NEW/Apps/Androidbuild/LEGOBuilder.apk"}]}]
[debug] [[email protected]] Event ‘newSessionRequested’ logged at 1679036544601 (08:02:24 GMT+0100 (Central European Standard Time))
[BaseDriver] Ignoring capability ‘appium:platformName=Android’ and using capability ‘platformName=Android’
[BaseDriver] The capabilities [“platformName”] are standard capabilities and do not require “appium:” prefix
[Appium] Could not parse W3C capabilities: ‘automationName’ can’t be blank
[debug] [[email protected]] Event ‘newSessionStarted’ logged at 1679036544605 (08:02:24 GMT+0100 (Central European Standard Time))
[debug] [[email protected]] Encountered internal error running command: InvalidArgumentError: ‘automationName’ can’t be blank
[debug] [[email protected]] at processCapabilities (/Users/usrname/.nvm/versions/node/v19.7.0/lib/node_modules/appium/node_modules/@appium/base-driver/lib/basedriver/capabilities.js:329:13)
[debug] [[email protected]] at parseCapsForInnerDriver (/Users/usrname/.nvm/versions/node/v19.7.0/lib/node_modules/appium/lib/utils.js:135:40)
[debug] [[email protected]] at AppiumDriver.createSession (/Users/usrname/.nvm/versions/node/v19.7.0/lib/node_modules/appium/lib/appium.js:254:49)
[debug] [[email protected]] at commandExecutor (/Users/usrname/.nvm/versions/node/v19.7.0/lib/node_modules/appium/node_modules/@appium/base-driver/lib/basedriver/driver.js:122:18)
[debug] [[email protected]] at AppiumDriver.executeCommand (/Users/usrname/.nvm/versions/node/v19.7.0/lib/node_modules/appium/node_modules/@appium/base-driver/lib/basedriver/driver.js:139:15)
[debug] [[email protected]] at processTicksAndRejections (node:internal/process/task_queues:95:5)
[debug] [[email protected]] at defaultBehavior (/Users/usrname/.nvm/versions/node/v19.7.0/lib/node_modules/appium/lib/appium.js:681:16)
[debug] [[email protected]] at AppiumDriver.executeWrappedCommand (/Users/usrname/.nvm/versions/node/v19.7.0/lib/node_modules/appium/lib/appium.js:775:16)
[debug] [[email protected]] at AppiumDriver.executeCommand (/Users/usrname/.nvm/versions/node/v19.7.0/lib/node_modules/appium/lib/appium.js:697:17)
[debug] [[email protected]] at asyncHandler (/Users/usrname/.nvm/versions/node/v19.7.0/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/protocol.js:387:19)
[HTTP] <-- POST /wd/hub/session 400 48 ms - 1496
[HTTP]

Probably don’t need this:

This just seems like a capitalization issue that @mykola-mokhnach was talking about:

So ‘AutomationName’ != ‘automationName’

List of capabilities is here:
https://appium.io/docs/en/writing-running-appium/caps/