Home >Java >javaTutorial >How to Bypass Deprecated Subresource Warnings When Using Selenium for Basic Authentication?
Selenium Basic Authentication via URL
Problem:
When using Selenium tests with Chromedriver-2.24, attempting to access a webpage through basic authentication using the following code results in a warning about deprecated subresource requests with embedded credentials:
WebDriver driver = ...; driver.get("http://admin:admin@localhost:8080/project/");
Solution:
1. Use Basic Authentication on the Domain:
The restriction on embedded credentials applies only to subresource requests. Therefore, you can still use basic authentication on the domain:
driver.get("http://admin:admin@localhost:8080"); driver.get("http://localhost:8080/project");
2. Use a Chrome Extension:
Alternatively, you can create a small Chrome extension to automatically set the credentials when requested:
options = webdriver.ChromeOptions() options.add_extension(r'C:\dev\credentials.zip')
The linked Gist provides a sample Python script that demonstrates this approach:
https://gist.github.com/florentbr/25246cd9337cebc07e2bbb0b9bf0de46
The above is the detailed content of How to Bypass Deprecated Subresource Warnings When Using Selenium for Basic Authentication?. For more information, please follow other related articles on the PHP Chinese website!