如何关闭验证弹出硒IE的webdriver? [英] how to close authentication pop up in Selenium IE webdriver?

查看:115
本文介绍了如何关闭验证弹出硒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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆