简体   繁体   English

DesiredCapabilities 由于其保护级别而无法访问

[英]DesiredCapabilities is inaccessible due to its protection level

I'm new to programming and I have worked in Python Selenium for web automation in the past.我是编程新手,过去曾在 Python Selenium 为 web 自动化工作。 Now, I'm using Appium Windows driver to automate Desktop UI using C#.现在,我正在使用 Appium Windows 驱动程序使用 C# 自动化桌面 UI。 Here is the sample code which I trying to work with,这是我尝试使用的示例代码,

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

namespace CalculatorTest
{
    public class CalculatorSession
    {
        // Note: append /wd/hub to the URL if you're directing the test at Appium
        private const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723";
        private const string CalculatorAppId = "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App";

        protected static WindowsDriver<WindowsElement> session;

        public static void Setup(TestContext context)
        {
            // Launch Calculator application if it is not yet launched
            if (session == null)
            {
                // Create a new session to bring up an instance of the Calculator application
                // Note: Multiple calculator windows (instances) share the same process Id
                DesiredCapabilities appCapabilities = new DesiredCapabilities();
                appCapabilities.SetCapability("app", CalculatorAppId);
                appCapabilities.SetCapability("deviceName", "WindowsPC");
                session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities);
                Assert.IsNotNull(session);

                // Set implicit timeout to 1.5 seconds to make element search to retry every 500 ms for at most three times
                session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1.5);
            }
        }

        public static void TearDown()
        {
            // Close the application and delete the session
            if (session != null)
            {
                session.Quit();
                session = null;
            }
        }
    }
}

I'm getting an error says "DesiredCapabilities is inaccessible due to its protection level".我收到一条错误消息,提示“DesiredCapabilities 由于其保护级别而无法访问”。 Can you please tell me how I can overcome this error?你能告诉我如何克服这个错误吗?

Now I ran into the same thing.现在我遇到了同样的事情。 Downgrading Selenium.WebDriver helped.降级 Selenium.WebDriver 有帮助。 Decreased to 3.10降至 3.10

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM