运行Selenium Webdriver Test时,没有出现警报

编程入门 行业动态 更新时间:2024-10-10 17:24:29
本文介绍了运行Selenium Webdriver Test时,没有出现警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在FireFox中运行Selenium Webdriver测试.单击按钮后,必须出现Javascript(JQuery/Bootstrap)警报,但是无论我如何运行程序(Eclipse,调试模式,可执行Jar),该警报都不会出现.

I'm running a Selenium webdriver test in FireFox. After clicking on a button a Javascript (JQuery/Bootstrap) alert has to appear but no matter how I run the program (eclipse, debug mode, executable Jar) this alert never appears.

当手动执行完全相同的操作时,即使我使用的是由Selenium Webdriver测试启动的相同浏览器会话,也会始终显示警报.我正在Windows 10下使用Selenium Webdriver 2.53 Java 1.7 Firefox 46.0.1.

When executing exactly the same action by hand the alert appears always, even when I used the same browser session that was started up by the Selenium webdriver test. I'm using Selenium Webdriver 2.53 Java 1.7 Firefox 46.0.1 under Windows 10.

任何人都不知道此警报的原因

Anybody an idea why this alert doesn't appear

推荐答案

实际上,默认情况下,在Firefox的Selenium Webdriver中,如果显示警告框,则将其关闭.

Actually in Selenium webdriver for Firefox by default the alert box is dismissed if it is appear.

因此,在初始化WebDriver之前,请通过如下设置来修改DesiredCapabilities,以忽略此行为:-

So modify your DesiredCapabilities before initializing WebDriver to ignore this behavior by setting as follows :-

DesiredCapabilities capabilities = DesiredCapabilities.firefox() capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR,"ignore");

希望这会对您有所帮助.

Hope this will help you..

更多推荐

运行Selenium Webdriver Test时,没有出现警报

本文发布于:2023-11-27 16:24:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638739.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   Selenium   Webdriver   Test

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!