Home >Java >javaTutorial >How Can I Implement Basic Authentication with Selenium Despite Chrome's Credential Warning?
Basic Authentication with Selenium Despite Browser Credentials Warning
When attempting to access a webpage via basic authentication using Selenium, you may encounter a warning from Google Chrome indicating that embedded credentials in URLs are blocked. This is due to the deprecation of this feature in Chrome.
Despite this, there are still alternative methods to perform basic authentication with Selenium:
Domain-Level Authentication:
You can specify the credentials as part of the domain rather than the subresource:
driver.get("http://admin:admin@localhost:8080"); driver.get("http://localhost:8080/project");
Chrome Extension for Automatic Credential Handling:
Create a Chrome extension that automatically sets the necessary credentials when requested:
options = webdriver.ChromeOptions() options.add_extension(r'C:\dev\credentials.zip')
Code Sample:
https://gist.github.com/florentbr/25246cd9337cebc07e2bbb0b9bf0de46
The above is the detailed content of How Can I Implement Basic Authentication with Selenium Despite Chrome's Credential Warning?. For more information, please follow other related articles on the PHP Chinese website!