首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用Selenium处理IE [Windows 10]中的Windows安全弹出窗口

如何使用Selenium处理IE [Windows 10]中的Windows安全弹出窗口
EN

Stack Overflow用户
提问于 2017-04-28 03:46:00
回答 4查看 9.7K关注 0票数 3

所以我使用Selenium Webdriver。在运行Windows 7的计算机上,我可以使用以下命令处理Windows安全弹出窗口

代码语言:javascript
复制
driver.switchTo().alert().authenticateUsing(new UserAndPassword([Credentials]));

但在Windows10中,我做不到。程序不会将其识别为警报,只是暂停,直到它终止。我尝试过研究类似的问题,但没有成功。这在IE中仍然有效,但在Edge中不起作用。

EN

回答 4

Stack Overflow用户

发布于 2019-10-31 00:01:44

您可以使用Raj的答案,但您不需要使用Sikuli框架。您可以使用java.awt.Robot将击键发送到Windows安全弹出窗口。在下面的示例中,机器人键入用户ID "U",然后切换到密码框,键入密码"P",并键入Enter键以关闭弹出窗口。

代码语言:javascript
复制
   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);
    }

希望能对你有所帮助。

票数 1
EN

Stack Overflow用户

发布于 2018-06-02 03:30:11

代码语言:javascript
复制
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

代码语言:javascript
复制
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);    
票数 0
EN

Stack Overflow用户

发布于 2018-12-13 00:01:32

以下策略适用于我以及IE安全设置

代码语言:javascript
复制
`UserAndPassword UC = new UserAndPassword(userName, password);
driver.switchTo().alert().authenticateUsing(UC);`
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43666687

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档