Home > Java > javaTutorial > How to Bypass Deprecated Subresource Warnings When Using Selenium for Basic Authentication?

How to Bypass Deprecated Subresource Warnings When Using Selenium for Basic Authentication?

Mary-Kate Olsen
Release: 2024-12-25 05:36:16
Original
611 people have browsed it

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/");
Copy after login

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");
Copy after login

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')
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template