简体   繁体   中英

Java-Selenium Allow Popup Window

I got a problem when I create my automation project. Firefox is blocking our web app's popup window. I try to enable it from about:preferences#content. But when I run the test firefox still blocking it. I also tried to use setPreference(), but no luck as well. I can't use firefox user profile because eventually, this program will give to all the QA member. Here is the setPreference() code that I tried.

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. 在此处输入图片说明
  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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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