亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 Selenium WebDriver 處理 Windows NTLM 身份驗證

使用 Selenium WebDriver 處理 Windows NTLM 身份驗證

ABOUTYOU 2022-06-15 15:18:49
我正在嘗試針對使用 NTLM 身份驗證協議的 Web 應用程序運行 selenium Web 驅動程序(Firefox)測試用例。我使用 DesiredCapabilities 將“network.automatic-ntlm-auth.trusted-uris”值更新為“ http://localhost:8080 ”以避免顯示身份驗證窗口?!?nbsp;network.automatic-ntlm-auth.trusted-uris”值已更新,但在瀏覽器中仍為空。問題:如何設置“network.automatic-ntlm-auth.trusted-uris”值?解決此問題的最佳方法是什么?請查看屏幕截圖和下面的代碼以獲取更多詳細信息。提前致謝。public RemoteWebDriver getWebDriverObject(DesiredCapabilities capabilities) {        String os = SystemUtils.IS_OS_WINDOWS ? "windows" : "linux";        System.setProperty("webdriver.gecko.driver", "target/test-classes/selenium_standalone_binaries/" + os + "/marionette/64bit/geckodriver.exe");        FirefoxOptions options = new FirefoxOptions();        // check the "Network.automatic-ntlm-auth.trusted-uris value before update"        System.out.println("Capability before update >>>>>" + capabilities.getCapability("Network.automatic-ntlm-auth.trusted-uris"));        // update the "Network.automatic-ntlm-auth.trusted-uris value" after update        capabilities.setCapability("Network.automatic-ntlm-auth.trusted-uris", "http://localhost:8080");        // check the "Network.automatic-ntlm-auth.trusted-uris value after update"        System.out.println("Capability after update >>>>>" + capabilities.getCapability("Network.automatic-ntlm-auth.trusted-uris"));        options.merge(capabilities);        options.setHeadless(HEADLESS);        return new FirefoxDriver(options);    }
查看完整描述

1 回答

?
拉丁的傳說

TA貢獻1789條經驗 獲得超8個贊

問題已經解決了。我必須使用 FirefoxProfile 來覆蓋所有瀏覽器配置值。


請檢查此以獲取更多詳細信息。


public RemoteWebDriver getWebDriverObject(DesiredCapabilities capabilities) {

        String os = SystemUtils.IS_OS_WINDOWS ? "windows" : "linux";

        System.setProperty("webdriver.gecko.driver", "target/test-classes/selenium_standalone_binaries/" + os + "/marionette/64bit/geckodriver.exe");


        FirefoxOptions options = new FirefoxOptions();

        options.merge(capabilities);

        options.setHeadless(HEADLESS);


        FirefoxProfile profile = new FirefoxProfile();

        profile.setPreference("network.automatic-ntlm-auth.trusted-uris", "http://localhost:8080");

        profile.setPreference("dom.disable_beforeunload", false);


        options.setProfile(profile);

        options.setLogLevel(FirefoxDriverLogLevel.DEBUG);

        return new FirefoxDriver(options);

    }


查看完整回答
反對 回復 2022-06-15
  • 1 回答
  • 0 關注
  • 255 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號