WinAppDriver: Appium Dotnet 5.0.0-beta01: Cannot instantiate WIndowsDriver: AppiumOptions "Vendor Prefix" causing driver instantiation error

I was trying out the Appium 5.0.0 Beta01. My capabilities/options looked like this:

            var options = new AppiumOptions();
            options.AddAdditionalCapability("app", "root");
            options.AddAdditionalCapability("ms:experimental-webdriver", true);

            WindowsDriver driver = new WindowsDriver(new Uri(WinAppDriverUrl), options, TimeSpan.FromSeconds(60));

but this set of options, specifically the option for (“app”, "root), threw this error: There is already an option for the appium:app capability. Please use the Application property instead. Parameter name: capabilityName

so I replaced it with this property instead: options.App = "root"; which apparently passes the capability as (“appiumoption:app”,“root”) instead of the old (“app”, “root”) key-value pair. and so now I get this errorr: OpenQA.Selenium.WebDriverArgumentException: Bad capabilities. Specify either app or appTopLevelWindow to create a session

I looked into the Appium dotnet source code and looks like the AppiumOptions class’s method to create a new AppiumOption has been modified: AppiumOptions.cs diff: Appium 4.3.1 vs 5.0.0 Beta01 This method in particular seems to have brought the change, adding a vendor prefix before any and all additional options/capabilities:

public void AddAdditionalAppiumOption(string optionName, object optionValue)
        {
            string name = optionName.Contains(":") ? optionName : $"{VendorPrefix}:{optionName}";
            this.ValidateCapabilityName(name);
            this.additionalAppiumOptions[name] = optionValue;
        }

I couldn’t find any way to get around it. Here’s a ticket for this issue in the Appium Dotnet Repo: https://github.com/appium/appium-dotnet-driver/issues/487

@kat-y @DHowett Is this being taken care of for the next release? This is a blocker on the upgrade path to Selenium 4 and Appium 5.

About this issue

Most upvoted comments

Hi all, I am stuck as well. My test stopped working previous week on this error:

System.TypeLoadException : Access is denied: 'OpenQA.Selenium.Remote.DesiredCapabilities'.

So I have started to solve it, I have tried perhaps all possibility combinations:

  • Update Appium.WebDriver (Nuget package in C# project) from 4.3.1 to 5.0b
    • there were described problem above (“Bad capabilities. Specify either app or appTopLevelWindow to create a session”)
  • Downgrade Appium.WebDriver into lower version (e.g. 4.0) with Selenium 3.141
    • there were problem, that Appium still uses 4.x Selenium version, probably due to another project in Solution, which uses higher Selenium
  • Link Appium.WebDriver as a standalone project into Solution without Nuget
    • the same problem, higher Selenium has been used
  • Remove Nuget of Appium.WebDriver and starting own Appium server as described above (http://127.0.0.1:4725/wd/hub)
    • problem with starting of application and WinAppDriver has been solved
    • but there were new problem, Finding elements stop working and new one (MobileBy.Name) works only for Notepad example, but not for my application