我以不同的用户身份运行 IEDriverServer。
RunAs("C:\\Exlporer/IEDriverServer.exe", "User","Password");
_webdriverIE = new InternetExplorerDriver();
var CustomerPage = new CRMLogin(_webdriverIE).GoToCRMURL("http://foo.com");
public 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 SecureString MakeSecureString(string text)
{
SecureString secure = new SecureString();
foreach (char c in text)
{
secure.AppendChar(c);
}
return secure;
}
我想打开 IE 浏览器,但是将它“连接”到我刚刚打开的现有驱动程序。
当调用 to 时InternetExplorerDriver
,它会打开一个新的驱动程序会话(当然),而前一个会话在识别元素等方面没有任何意义。
_webdriverIE = new InternetExplorerDriver();
我可以将浏览器连接到现有的InternetExplorerDriver
吗?