Basic Authentication in Selenium Without Using URL-Embedded Credentials
In Selenium, basic authentication is commonly handled by embedding credentials in the URL. However, this method is now deprecated in Chrome due to security concerns. This raises the question of how to perform basic authentication effectively without using URL-embedded credentials.
Alternative Methods for Basic Authentication
Fortunately, there are still viable options for basic authentication in Selenium:
driver.get("http://admin:admin@localhost:8080"); driver.get("http://localhost:8080/project");
options = webdriver.ChromeOptions() options.add_extension(r'C:\dev\credentials.zip')
Example Extension Script
A sample extension for automatic credential insertion can be found in the following gist:
https://gist.github.com/florentbr/25246cd9337cebc07e2bbb0b9bf0de46
By incorporating these alternative methods into your Selenium tests, you can effectively perform basic authentication without resorting to URL-embedded credentials. This ensures compatibility with the latest Chrome versions and maintains the security of your authentication processes.
The above is the detailed content of How to Perform Basic Authentication in Selenium Without Using URL-Embedded Credentials?. For more information, please follow other related articles on the PHP Chinese website!