Home > database >  Appium WebDriver WinAppDriver Error - Defined in 'WebDriver', but it could not be found Er
Appium WebDriver WinAppDriver Error - Defined in 'WebDriver', but it could not be found Er

Time:07-28

I'm currently trying to run the following code in order to automate Windows desktop apps with WinAppDriver in C#.

Whenever I enter the following code WindowsDriver<WindowsElement> _driver;

I get multiple errors show up in my error list, they are all very similar in nature and this is just one of them for example purposes.

Severity Code Description Project File Line Suppression State Error CS7069 Reference to type 'IFindsByTagName' claims it is defined in 'WebDriver', but it could not be found Windows Apps Automation C:\Installs\Windows App Automation\Windows Apps Automation\UnitTest1.cs 18 Active

Here is the main body of code i'm currently trying to build / execute.

using System;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Windows;
using OpenQA.Selenium.Remote;        

[TestClass]
    public class UnitTest1
    {
        [TestFixture]
        public class CalculatorTests
        {
            private WindowsDriver<WindowsElement> _driver;
            [SetUp]
            public void TestInit()
            {
                var options = new AppiumOptions();
                options.AddAdditionalCapability("app", "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App");
                options.AddAdditionalCapability("deviceName", "WindowsPC");
                _driver = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), options);
                _driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
            }

The error that displays is always on the WindowsElement section for each instance that it's referred to in the code. The error is always the same.

Here are the packagaes and versions that i'm currently using

    <packages>
  <package id="Appium.WebDriver" version="4.3.2" targetFramework="net472" />
  <package id="Castle.Core" version="5.0.0" targetFramework="net472" />
  <package id="DotNetSeleniumExtras.PageObjects" version="3.11.0" targetFramework="net472" />
  <package id="DotNetSeleniumExtras.PageObjects.Core" version="4.3.0" targetFramework="net472" />
  <package id="DotNetSeleniumExtras.WaitHelpers" version="3.11.0" targetFramework="net472" />
  <package id="Microsoft.CodeCoverage" version="17.2.0" targetFramework="net472" />
  <package id="Microsoft.NET.Test.Sdk" version="17.2.0" targetFramework="net472" />
  <package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
  <package id="NUnit" version="3.13.3" targetFramework="net472" />
  <package id="Selenium.Support" version="4.3.0" targetFramework="net472" />
  <package id="Selenium.WebDriver" version="4.3.0" targetFramework="net472" />

I'm not sure what i'm missing or not referring to, others have used this exact code before me without issue and I've set it up in the same way, which is why im confused as to the errors.

Any help would be greatly appreciated.

Thanks

CodePudding user response:

I have located the issue to the original problem stated above.

The issue is related to the package dependancies of Appium Webdriver that I was using. The versions of some of the packages that I was using were too new.

These are the dependancies that are required for the errors to be cleared.

Package versions required

You need to make sure that all of these additional packages that you install match the versions listed in the above image. If you don't then the original error will be displayed to you.

CodePudding user response:

WinAppDriver is not supported by Selenium 4 due WinAppDriver is not yet W3C compliant. You should use Selenium Pre 4.0 (e.g. version 3.4) for all Selenium libraries

  • Related