簡體   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