简体   繁体   English

按功能隐藏 Windows 离开/取消弹出窗口

[英]Hide Windows Leave/Cancel Pop-up by capabilities

I'm working with Selenium, Java and Browserstack.我正在使用 Selenium、Java 和 Browserstack。 Usually I develop in MacOS and I improve the compatibility with the remote browser.通常我在 MacOS 中开发,并提高与远程浏览器的兼容性。 I'm trying to execute the same test cases that are working properly in MacOS, into a Windows remote machine.我正在尝试将在 MacOS 中正常工作的相同测试用例执行到 Windows 远程机器中。

The problem appears when I let a form incomplete because and I have clicked on a Cancel button to back again to the previous page.当我让表单不完整时会出现问题,因为我单击了取消按钮以再次返回上一页。 In this scenario the default chrome alert appears:在这种情况下,会出现默认的 chrome 警报:

在此处输入图像描述

I have tried the Chrome option:我尝试了 Chrome 选项:

options.addArguments("--disable-notifications");

Also:还:

options.addArguments("--disable-popup-blocking");

And with:与:

prefs.put("profile.default_content_settings.popups", 0);

I know I can use a condition in the cancel button associated to the system configuration, where the selenium code accept the alert, but I'm searching an option more cleaning and easy.我知道我可以在与系统配置关联的取消按钮中使用一个条件,其中 selenium 代码接受警报,但我正在寻找一个更清洁和简单的选项。

Do you know any other option, capability or whatever, that could block those pop-ups but not the others?您是否知道任何其他选项、功能或其他任何可以阻止这些弹出窗口但不能阻止其他弹出窗口的选项?

Thank you in advance.先感谢您。

EDIT NOTE It is something related with Chrome pop-ups only.编辑注意这仅与 Chrome 弹出窗口有关。

Please try prefs.put("profile.default_content_setting_values.notifications", 2);请尝试 prefs.put("profile.default_content_setting_values.notifications", 2);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM