Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用Selenium WebDriver处理Windows NTLM身份验证_Java_Firefox_Selenium Webdriver_Ntlm Authentication - Fatal编程技术网

Java 使用Selenium WebDriver处理Windows NTLM身份验证

Java 使用Selenium WebDriver处理Windows NTLM身份验证,java,firefox,selenium-webdriver,ntlm-authentication,Java,Firefox,Selenium Webdriver,Ntlm Authentication,我正在尝试对使用NTLM身份验证协议的web应用程序运行SeleniumWeb驱动程序(Firefox)测试用例 我使用DesiredCapabilities将“network.automatic ntlm auth.trusted URI”值更新为“”以避免显示身份验证窗口 “network.automatic ntlm auth.trusted uris”值已更新,但在浏览器中仍然为空 问题: 如何设置“network.automatic ntlm auth.trusted uris”值 解

我正在尝试对使用NTLM身份验证协议的web应用程序运行SeleniumWeb驱动程序(Firefox)测试用例

我使用DesiredCapabilities将“network.automatic ntlm auth.trusted URI”值更新为“”以避免显示身份验证窗口

“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);
        }
    


    问题解决了。我必须使用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);
        }
    

    问题解决了。我必须使用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);
        }
    
    “SSO”是一个非常广泛的术语,现在通常指OAuth2。如果您明确表示正在尝试使用Windows NTLM,您可能会得到更好的回复。“SSO”是一个非常宽泛的术语,现在通常指OAuth2。如果您明确表示正在尝试使用Windows NTLM,您可能会得到更好的回复。