In my Selenium-Test
(with chromedriver-2.24
) I\'m trying to access my webpage via basic authentication with the following statement:
Florent B.'s approach of calling .get on the URL twice worked for me with a slight modification. In JS:
driver
.get('http://admin:admin@localhost:8080')
.then( () => driver.get('http://localhost:8080') )
working on google chrome 62.0.3202.94 with ChromeDriver 2.33.506092 and the approach seems compatible with firefox 56.0.2 with geckodriver 0.19.1, and phantomjs 2.1.1 all under Debian linux 9.
What I believe is happening is the first call sets up the Authorization header sent by the browser. The second call removes the credentials from the URL and the credentials no longer are applied to subresources. The then
synchronizes the two requests ensuring order.