简体   繁体   English

Java-硒允许弹出窗口

[英]Java-Selenium Allow Popup Window

I got a problem when I create my automation project. 创建自动化项目时遇到问题。 Firefox is blocking our web app's popup window. Firefox阻止了我们Web应用程序的弹出窗口。 I try to enable it from about:preferences#content. 我尝试从about:preferences#content启用它。 But when I run the test firefox still blocking it. 但是,当我运行测试Firefox时,仍将其阻止。 I also tried to use setPreference(), but no luck as well. 我也尝试使用setPreference(),但也没有运气。 I can't use firefox user profile because eventually, this program will give to all the QA member. 我无法使用firefox用户个人资料,因为最终,该程序将提供给所有QA成员。 Here is the setPreference() code that I tried. 这是我尝试过的setPreference()代码。

public void LoginCad(){

    //System.setProperty("webdriver.firefox.bin", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");

    System.setProperty("webdriver.gecko.driver", "C:\\Program Files (x86)\\Mozilla Firefox\\geckodriver.exe");

    FirefoxProfile profile = new FirefoxProfile();

    profile.setPreference("dom.disable_open_during_load", false);
    profile.setPreference("privacy.popups.disable_from_plugins", 0);
    profile.setPreference("privacy.popups.policy", 1);
    profile.setPreference("dom.max_script_run_time", "999");

    driver = new FirefoxDriver(profile);

    driver.get("http://172.16.1.133:8090/CADENCIE/servlet/app");

Thank you very much. 非常感谢你。

You can try this: 您可以尝试以下方法:

  1. Click on the permission symbol appears in the search bar in firfox browser. 单击权限符号会出现在firfox浏览器的搜索栏中。 在此处输入图片说明
  2. Click on right arrow displayed in first row then select More Information 单击第一行中显示的向右箭头,然后选择“ 更多信息”
  3. Page Info dialog will open. 页面信息对话框将打开。 Navigate to Permissions tab. 导航到“权限”选项卡。
  4. Scroll down to see Open pop-up windows. 向下滚动以查看“打开”弹出窗口。 Change settings to Allow 将设置更改为允许 在此处输入图片说明

您可以尝试以下方法:

profile.setPreference("browser.popups.showPopupBlocker", false);

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

相关问题 如何通过使用Java在Selenium Webdriver中的弹出窗口上单击允许按钮 - How to click on allow button on popup window in selenium Webdriver by using Java Java-Selenium:TakesScreenshot大小问题 - Java-Selenium : TakesScreenshot size issue 找不到Java-Selenium WebElement错误 - Java-Selenium WebElement is not found error 无法在 Java-Selenium 中找到元素错误 - Unable to locate element error in Java-Selenium iframe 内的 Actions 类操作(Java-Selenium) - Actions class operations inside iframe(Java-Selenium) Selenium Webdriver-如何使用Java关闭弹出窗口 - Selenium Webdriver - How to close popup window with java 使用 Python-Selenium 启动 IE 时出错,而完全相同的脚本在 Java-Selenium 中运行良好 - Error in launching IE with Python-Selenium while the exact same script works fine with Java-Selenium 使用 java-selenium 运行黄瓜测试时出现“java.lang.OutOfMemoryError”异常 - Getting "java.lang.OutOfMemoryError" exception while running a cucumber test using java-selenium 如何通过命令提示符/终端运行Java-Selenium测试用例? - How to run Java-Selenium test cases through command prompt/terminal? 如何使用java-selenium中的黄瓜bdd框架处理bootstrap下拉列表 - how to handle bootstrap dropdown using the cucumber bdd framework in java-selenium
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM