java - 在 selenium 自动化期间绕过 "External protocol request"弹出窗口

标签 java testing selenium selenium-webdriver webdriver

我在 mac 和 ubunto 上运行自动化(使用 cucumber、selenium 网络驱动程序、junit)

在自动化过程中,我点击了一个非 http 协议(protocol)的链接

出现“外部协议(protocol)请求”弹出窗口。

enter image description here

它阻止我的测试测试网页的其余部分。

如何轻松绕过它?

我想也许可以编写一个什么也不做的 jar,然后将其注册到这个外部协议(protocol),但它无济于事,因为这个弹出窗口仍然会出现。

也许使用其他浏览器会有帮助?

还有什么建议吗?

最佳答案

我将 chromedriver 与 selenium 和 python 结合使用。 我遇到了同样的问题,下面的代码对我有用-

driver.execute_script("window.confirm = function(msg) { return true; }")

prefs = {"protocol_handler.excluded_schemes":{"afp":True,"data":True,"disk":True,"disks":True,"file":True,"hcp":True,"intent":True, "itms-appss":True, "itms-apps":True,"itms":True,"market":True,"javascript":True,"mailto":True,"ms-help":True,"news":True,"nntp":True,"shell":True,"sip":True,"snews":False,"vbscript":True,"view-source":True,"vnd":{"ms":{"radio":True}}}}    

chrome_options.add_experimental_option("prefs",prefs)

假设您想抑制以“sip://”开头的链接的协议(protocol)处理程序弹出
只需在 "protocol_handler.excluded_schemes"

中添加一个额外的条目作为 "sip":True

关于java - 在 selenium 自动化期间绕过 "External protocol request"弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29554564/

相关文章:

javascript - 通过循环遍历 Javascript 中的 findElements 结果来查找特定元素

java - 当 validator 发现表单错误时,表单页面将在 POST url 处重新显示

java - 为什么我的项目导入jdk 1.8,而pom.xml设置jdk 1.7?

java - 是否可以使用 BufferedReader 反转文件的每一行?

jQuery 正则表达式无法正常工作

python-3.x - 如何从 PDF 嵌入 HTML 的 URL 下载 PDF 文件?

java - 获取应用程序路径以创建新文件

perl - 我如何测试一个特性何时被添加到 Perl?

python - 在 python 模块中测试示例代码

python - selenium.common.exceptions.ElementClickInterceptedException : Message: element click intercepted: