C# 所需的功能已过时

C# 所需的功能已过时,c#,selenium,selenium-webdriver,desiredcapabilities,C#,Selenium,Selenium Webdriver,Desiredcapabilities,为了以不同的用户身份运行驱动程序,我使用了以下代码 public static IWebDriver RunIEAsDifferentUser(string User,string Password) { var capabilitiesInternet = DesiredCapabilities.InternetExplorer(); capabilitiesInternet.SetCapability("ignoreProtectedModeSet

为了以不同的用户身份运行驱动程序,我使用了以下代码

 public static IWebDriver RunIEAsDifferentUser(string User,string Password)
    {

        var capabilitiesInternet = DesiredCapabilities.InternetExplorer();
        capabilitiesInternet.SetCapability("ignoreProtectedModeSettings", true);
        capabilitiesInternet.SetCapability("EnsureCleanSession ", true);
        RunAs("C:\\Exlporer/IEDriverServer.exe", User, Password);
        _webdriverIE = new RemoteWebDriver(new Uri("http://localhost:5555/"), capabilitiesInternet, TimeSpan.FromSeconds(300));
        return _webdriverIE;

    }
    public static void RunAs(string path, string username, string password)
    {
        ProcessStartInfo myProcess = new ProcessStartInfo(path);
        myProcess.UserName = username;
        myProcess.Password = MakeSecureString(password);
        myProcess.UseShellExecute = false;
        myProcess.LoadUserProfile = true;
        myProcess.Verb = "runas";
        myProcess.Domain = "DOM001";
        Process.Start(myProcess);
    }

    public static SecureString MakeSecureString(string text)
    {
        SecureString secure = new SecureString();
        foreach (char c in text)
        {
            secure.AppendChar(c);
        }

        return secure;
    }
问题是我得到了警告:
DesiredCapabilities已经过时了
,我不确定我必须做什么才能让它继续工作

有问题的行是:
\u webdriverIE=new RemoteWebDriver(新Uri(“http://localhost:5555/)、能力互联网、时间跨度从秒(300))
我已尝试将其更改为
InternetExplorerOptions caps=newInternetExploreRoptions()
不幸的是,
RemoteWebDriver
现在只接受
Icapabilities

解决方案位于警告消息的末尾

要与Java远程服务器或网格一起使用,请使用InternetExploreProptions类的ToCapabilites方法


我刚注意到。。无论如何,谢谢!:-)
InternetExplorerOptions options = new InternetExplorerOptions();
options.AddAdditionalCapability("ignoreProtectedModeSettings", true);
options.AddAdditionalCapability("EnsureCleanSession", true);
_webdriverIE = new RemoteWebDriver(new Uri("http://localhost:5555/"), options.ToCapabilities(), TimeSpan.FromSeconds(300));