Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle basic authentication with protractor?

Tags:

I'm trying protractor to write a few tests in a non angular application. I have to login in a page trough basic authentication in google chrome, but i have no idea how.

Authentication box

I already tried baseUrl: 'https://username:password@url' and capabilities: { 'browserName': 'chrome', 'chromeOptions' : { args: ['--login-user=foo', '--login-password=bar'] } }

But none if these worked for me. Anyone knows how to do it? I'm having some hard time on it.

like image 334
andrepm Avatar asked Dec 01 '14 18:12

andrepm


People also ask

How does a protractor handle basic authentication?

1) Find a chrome extension/plugin that allows you to modify header. A simple search bring up many of them: https://chrome.google.com/webstore/search/modify%20header. You'll need to add the plugin to webdriver: see Is it possible to add a plugin to chromedriver under a protractor test?. Show activity on this post.

How do I pass username and password in basic authentication?

1 Answer. It is indeed not possible to pass the username and password via query parameters in standard HTTP auth. Instead, you use a special URL format, like this: http://username:[email protected]/ -- this sends the credentials in the standard HTTP "Authorization" header.


1 Answers

In fact you can just set the url as http://username:[email protected]. Chrome will handle it!

like image 63
Nuno Ferreira Avatar answered Sep 17 '22 09:09

Nuno Ferreira