如何关闭验证弹出硒IE的webdriver? [英] how to close authentication pop up in Selenium IE webdriver?
问题描述
我有web应用程序被加载所以在自动化测试我是通过通过http://用户名:密码@域但是当我进入错误的凭据,弹出不会消失,它会等待正确的凭据。但我要测试是否有与错误的凭据网页上的访问,每一个浏览器是关闭没有问题,但IE是扔模态对话框present
I've got web application with browser authentication before webpage is loaded so in automated test i am log in via http://user:password@domain but when i am entering wrong credentials, pop up would not disappear it would wait for correct credentials. But i want to test if there is a access to webpage with wrong credentials, every browser is closing without problem, but IE is throwing
modal dialog present
我试图用
driver.SwitchTo().Alert().Dismiss();
,但它不工作。
任何想法如何关闭弹出身份验证?
but it doesn't work. any idea how to close that pop up authentication?
推荐答案
认证弹出
不是由生成的Javascript /它不是一个JavaScript警告。所以它不能由的webdriver处理。
Authentication popup
is NOT generated by Javascript / it is not a javascript alert. So It can not be handled by WebDriver.
您没有提及您使用的编程语言。你的样品code似乎是在C#。在Java中 - 我们有一个 java.awt.Robot中的
来模拟键盘事件。您可能必须找到C#相当于preSS ESC键。
You did not mention the programming language you use. Your sample code seems to be in C#. In Java - we have a java.awt.Robot
to simulate keyboard events. You might have to find C# equivalent to press the ESC key.
Robot robot = new Robot();
//Press ESC key
robot.keyPress(InputEvent.VK_ESCAPE);
robot.keyRelease(InputEvent.VK_ESCAPE);
这篇关于如何关闭验证弹出硒IE的webdriver?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!