我正在尝试使用以下代码处理身份验证弹出窗口:
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.http.phishy-userpass-length", 255);
profile.setPreference("network.automatic-ntlm-auth.trusted-uris", "x.x.x.x");
driver = new FirefoxDriver(profile);
baseUrl="http://" + login + ":" + password + "@" + url;
driver.get(baseUrl + "/");
当我执行测试时,页面显示身份验证弹出窗口,并且仍在加载,直到我单击取消按钮。那一刻,我可以访问下一个页面,这意味着身份验证成功,但仍然始终显示身份验证弹出窗口
警报方法,authenticateUsing() https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/Alert.html#authenticateUsing-org.openqa.selenium.security.Credentials-让您跳过HTTP基本认证 box.
WebDriverWait wait = new WebDriverWait(driver, 10);
Alert alert = wait.until(ExpectedConditions.alertIsPresent());
alert.authenticateUsing(new UserAndPassword(username, password));
As of 硒3.4它仍处于测试阶段
目前实施仅针对InternetExplorerDriver
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)