Protractor: Login Automatically

Created on 13 Aug 2014  路  16Comments  路  Source: angular/protractor

Hi Protractor

i have the follow question, there is a way to protractor, could login with user and password automatically when start the test E2E?

regards, Carlos Ceron
Thanks.

question

Most helpful comment

Is "chromeOptions" supposed to work with HTTP Basic Authentication?

I'm looking for a way to provide HTTP Basic Authentication login and password while opening a page.

All 16 comments

Hi

'automatically' means Basic Authentication for you? (without own Login-Page)

A solution may be setting the base-Url like this:

 baseUrl: 'https://username:password@url'

Another thing I found:
If you are using chrome for your Tests, there are the options --login-user and --login-password but I have never seen an example using them for Basic Authentication.

capabilities: {
        'browserName': 'chrome',
        'chromeOptions' : {
            args: ['--login-user=foo', '--login-password=bar']
        }
}

zakrhol automatically it's not without login page, i have a login form, but i need, when start to test let me go to routes because if you aren't login, you can't go to the path.

capabilities: {
'browserName': 'chrome',
'chromeOptions' : {
args: ['--login-user=foo', '--login-password=bar']
}
}

and with that way, the question it's how i can to say what are my login parameters?

and ending Thanks for your answer

regards
Carlos Ceron

if you have a login form(page) where user must enter name and passwort, then your test must go the same way.
config example with Login should help you. It navigates to login page, enters credentials and click ok. In your test you can navigate to the URL to test.

regards
ZakRhol

i don't know where i find this file, environment.js? the documentation is poor about this topic

var env = require('./environment.js');

Thanks

now, i have the file xD thanks, i try and share the result

Thanks, everyone

Sounds like this question has been answered - closing!

I'm having problems with my app's chrome login authentication.
It's obviously not visible in the DOM, so I can't sendKeys or click anything.
I've tried the "--login-user=myUser" and "-- login-password=myPass" in the chrome-options in my protractor config file, and it's not working. It just keeps getting stuck on the the authentication pop up.
I've also tried the "http://myUser:myPass@restOfUrl" and it's not working either.

Is "chromeOptions" supposed to work with HTTP Basic Authentication?

I'm looking for a way to provide HTTP Basic Authentication login and password while opening a page.

Hi,

I am desperating because a simple test I need to run. I need credentials (user/password on a popup entering the website) to enter the website, but here comes the funny thing: if I enter credentials manually, I go to a login page, that is, indeed, what I need to test, the login system. BUT, when I use "user:password@url" I go to a different page, empty, just with a name in the center. Not a matter of time because when I do it manually, writing "user:password@url" in chrome, I go to the same useless website.

So, as a summary, filling the popup is right (and I can't get how to do it from protractor test) but writing "user:password@url" goes to a useless website.

Did that happen to any of you? could you give some light into that?

thanks a lot in advance.
Niko.

Login authentication via URL doesn't work anymore in the browsers :(

@NikoMendez @grenader they changed the way basic auth works in chrome with v59. It basically blocks subresources from loading. It is supposed to be reverted in v61 and maybe v60. To get it working again in v59(also v60 if not reverted) you can set the flag as an argument in the Chrome options. Example:

    chromeOptions: {
      prefs: {
        credentials_enable_service: false
      },
      mobileEmulation: {
        deviceName: 'iPhone 6 Plus'
      },
      args: ['--disable-blink-features=BlockCredentialedSubresources']
    }

This will allow you to use basic auth in the url again (user:password@url).

@jessehonest thanks for your help, but I'm still getting the same result. Is there any other way to fill up the username and password without using that URL 'trick'?

Regards,
Niko.

@NikoMendez Not sure of autoit is an option with protractor.

@juliemr is there any way to skip the email verification during E2E protractor tests? What I mean is when the user register him/herself then he/she has to verify the email. Instead of going to the mailbox I would like to do server side authentication so the tests never have to go to user's/admin email box. Thanks in advance!

been following this..hopefully someone picks this up..:( badly needed (windows auth)

Was this page helpful?
0 / 5 - 0 ratings