繁体   English   中英

Java-硒允许弹出窗口

[英]Java-Selenium Allow Popup Window

创建自动化项目时遇到问题。 Firefox阻止了我们Web应用程序的弹出窗口。 我尝试从about:preferences#content启用它。 但是,当我运行测试Firefox时,仍将其阻止。 我也尝试使用setPreference(),但也没有运气。 我无法使用firefox用户个人资料,因为最终,该程序将提供给所有QA成员。 这是我尝试过的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");

非常感谢你。

您可以尝试以下方法:

  1. 单击权限符号会出现在firfox浏览器的搜索栏中。 在此处输入图片说明
  2. 单击第一行中显示的向右箭头,然后选择“ 更多信息”
  3. 页面信息对话框将打开。 导航到“权限”选项卡。
  4. 向下滚动以查看“打开”弹出窗口。 将设置更改为允许 在此处输入图片说明

您可以尝试以下方法:

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

暂无
暂无

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

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