Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Selenium处理IE[Windows 10]中的Windows安全弹出窗口_Selenium_Internet Explorer_Internet Explorer 8_Webdriver - Fatal编程技术网

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

如何使用Selenium处理IE[Windows 10]中的Windows安全弹出窗口,selenium,internet-explorer,internet-explorer-8,webdriver,Selenium,Internet Explorer,Internet Explorer 8,Webdriver,所以我使用的是SeleniumWebDriver。在运行Windows 7的计算机上,我可以使用 driver.switchTo().alert().authenticateUsing(new UserAndPassword([Credentials])); 但在Windows10中,我不能。程序不会将其识别为警报,只是暂停直到终止。我曾尝试研究类似的问题,但没有成功。这仍然在IE中工作,而不是在Edge中 我能够通过更改注册表来解决IE 11(Windows 10)中的IE基本身份验证问题。

所以我使用的是SeleniumWebDriver。在运行Windows 7的计算机上,我可以使用

driver.switchTo().alert().authenticateUsing(new UserAndPassword([Credentials]));

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

我能够通过更改注册表来解决IE 11(Windows 10)中的IE基本身份验证问题。如中所述,需要在以下位置创建
iexplore.exe
explorer.exe
键:

  • HKEY\u LOCAL\u MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE\u HTTP\u USERNAME\u PASSWORD\u DISABLE
  • HKEY\u LOCAL\u MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE\u HTTP\u USERNAME\u PASSWORD\u DISABLE
  • HKEY\u CURRENT\u USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE\u HTTP\u USERNAME\u PASSWORD\u DISABLE
它们应该是
DWORD
值,设置为0

这将允许您执行以下操作:

http://domain%5Cuser:password@example.com
其中
%5C
\

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/
在这里观看视频:


以下策略与IE安全设置一起适用于我

`UserAndPassword UC = new UserAndPassword(userName, password);
driver.switchTo().alert().authenticateUsing(UC);`

我最初在Windows10IE11中遇到了Windows安全警报问题。我尝试使用AutoIT(无法识别警报,但可以使用Tab-press)、切换到警报、身份验证、在URL中传递UID和PWD等,但它们对我不起作用。最后,在硒中使用Sikuli有效。下面是代码片段:

Screen s=new Screen();
//If you need to pass UID please add one more line of code here. For me only PWD field to fill.
s.type("PasswordField.png","Password");
s.find("Ok.png");
s.click("Ok.png);
如果您的应用程序在输入凭据之前一直在加载,那么在执行Sikuli脚本之前将出现
pageLoadTimeout
异常。为了克服这个异常,我尝试了下面的代码,它是有效的:

driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
try{
driver.get("URL");
} catch (TimeoutException e){
Screen s=new Screen();
s.type("PasswordField.png","Password");
s.find("Ok.png");
s.click("Ok.png);
}

您可以使用Raj的答案,但不需要使用Sikuli框架。您可以使用java.awt.Robot向Windows安全弹出窗口发送击键。在下面的示例中,机器人输入用户ID“U”,然后点击密码框,输入密码“P”,然后输入回车键关闭弹出窗口

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

希望它能帮助你

遗憾的是,Selenium绑定是这样的,Web驱动程序的维护人员对其驱动程序如何与Selenium api通信拥有最终决定权。Microsoft维护边缘驱动程序,您可能需要查询MSDN。@user2283704提供详细信息:1。你的确切测试步骤是什么?2.什么对你有用?显示代码。3.你被困在哪里了。4.提供错误跟踪。5.提供相关的HTML DOM。尝试更清楚地解释为什么这是问题的答案。首先,我们需要导入import org.openqa.selenium.security.UserAndPassword;我像往常一样调用浏览器并加载URL。使用上面的代码,我能够传递用户名和密码
   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);
    }