0
我曾經有以下代碼以便以不同的用戶身份運行驅動程序。DesiredCapabilities已過時
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
。
只是注意到它..謝謝反正! :-) –