所以我使用Selenium Webdriver。在运行Windows 7的计算机上,我可以使用以下命令处理Windows安全弹出窗口
driver.switchTo().alert().authenticateUsing(new UserAndPassword([Credentials]));但在Windows10中,我做不到。程序不会将其识别为警报,只是暂停,直到它终止。我尝试过研究类似的问题,但没有成功。这在IE中仍然有效,但在Edge中不起作用。
发布于 2019-10-31 00:01:44
您可以使用Raj的答案,但您不需要使用Sikuli框架。您可以使用java.awt.Robot将击键发送到Windows安全弹出窗口。在下面的示例中,机器人键入用户ID "U",然后切换到密码框,键入密码"P",并键入Enter键以关闭弹出窗口。
Robot robot = new Robot();
driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
try{
driver.get("URL");
} catch (TimeoutException e){
robot.keyPress(KeyEvent.VK_U);
robot.keyPress(KeyEvent.VK_TAB);
robot.keyPress(KeyEvent.VK_P);
robot.keyPress(KeyEvent.VK_ENTER);
}希望能对你有所帮助。
发布于 2018-06-02 03:30:11
I have work around, might be helpful here. Let me make some comments:
1. Selenium does not have capacity to handle IE "Windows Security" pop up.
Not even through "switch alert accept/ dismiss" concept.
2. You have to use third party tools such as AutoIT, this is what I used to handle IE pop up. But this tool has some limitations such as you can not lock you automation machine so you have to keep you test machine unlocked while test is in progress because of security reason (you can google it about).
3. Currently you can not even lock you machine while running IE Selenium Automation
Work around is here :
you may follow this link : http://learn-automation.com/handle-windows-authentication-using-selenium-webdriver/点击此处观看视频:https://www.youtube.com/watch?v=civzNtKTCD0&t=862s
1. Download AutoIT
2. Write up script using AutoIT editor
3. should like this for IE scenario:
WinWaitActive("Windows Security")
Send("username")
Send("{TAB}")
Send("password")
Send("{TAB}")
Send("{TAB}")
Send("{ENTER}")
4. Save it and right click -> compile it using 64 bit
5. now you will have a one exe , which can be used directly in your selenium code , for example :
driver = new InternetExplorerDriver(DrivePath);
driver.Manage().Window.Maximize(); System.Diagnostics.Process.Start(@"C:\Users\source\HandleAuthentication.exe"); driver.Navigate().GoToUrl(url); 发布于 2018-12-13 00:01:32
以下策略适用于我以及IE安全设置
`UserAndPassword UC = new UserAndPassword(userName, password);
driver.switchTo().alert().authenticateUsing(UC);`https://stackoverflow.com/questions/43666687
复制相似问题