对此进行了一些更新link:
Chromium Issue 435547在子资源请求中放弃对嵌入式凭据的支持。(已删除)
我们应该阻止对包含嵌入式凭据(例如“ http:// ima_user:hunter2@example.com/yay.tiff ”)的子资源的请求。这些资源将作为网络错误处理。
但是,基本身份验证功能仍然可以通过Selenium-Java绑定与Selenium 3.4.0,geckodriver v0.18.0,chromedriver v2.31.488763,Google Chrome 60.x和Mozilla Firefox 53.0一起使用。
这是示例代码,它尝试使用一组有效的凭据打开URL http://the-internet.herokuapp.com/basic_auth,并且可以正常工作。
Firefox:
import org.openqa.selenium.WebDriver;import org.openqa.selenium.firefox.FirefoxDriver;public class BasicAuthentication_FF { public static void main(String[] args) { System.setProperty("webdriver.gecko.driver", "C:\Utility\BrowserDrivers\geckodriver.exe"); WebDriver driver = new FirefoxDriver(); driver.navigate().to("http://admin:admin@the-internet.herokuapp.com/basic_auth"); }}Chrome:
import org.openqa.selenium.WebDriver;import org.openqa.selenium.chrome.ChromeDriver;import org.openqa.selenium.chrome.ChromeOptions;public class BasicAuthentication_Chrome { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "C:\Utility\BrowserDrivers\chromedriver.exe"); ChromeOptions options = new ChromeOptions(); options.addArguments("start-maximized"); options.addArguments("disable-infobars"); options.addArguments("--disable-extensions"); WebDriver driver = new ChromeDriver(options); driver.navigate().to("http://admin:admin@the-internet.herokuapp.com/basic_auth"); }}


