gpt4 book ai didi

c# - DesiredCapabilities 已过时

转载 作者:行者123 更新时间:2023-11-30 14:22:55 25 4
gpt4 key购买 nike

我曾经有以下代码,以便以不同的用户身份运行驱动程序。

 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 is obsolete 并且我不确定我必须做些什么才能让它继续工作。

有问题的行是:_webdriverIE = new RemoteWebDriver(new Uri("http://localhost:5555/"), capabilitiesInternet, TimeSpan.FromSeconds(300));我尝试将其更改为 InternetExplorerOptions caps = new InternetExplorerOptions();。不幸的是,RemoteWebDriver 现在只接受Icapabilities

最佳答案

解决方案在警告信息的最后

For use with the Java remote server or grid, use the ToCapabilites method of the InternetExplorerOptions class.

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));

关于c# - DesiredCapabilities 已过时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47863579/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com