Nightwatch: setting credentials for http basic auth is ignored?

Created on 12 Feb 2017  路  5Comments  路  Source: nightwatchjs/nightwatch

I've got a selenium hub running at https://admin:[email protected]

The following configuration should set basic auth headers (I tried to figure this out from the source):

  "test_settings" : {
    "default" : {
      "selenium_port"  : 443,
      "selenium_host"  : "selenium.myhost.com",
      "use_ssl": true,
      "credentials": {
        "username": "admin",
        "key": "secret"
      },

But it doesn't work:

Running:  Demo test Google
Error processing the server response:
 <html><body><h1>401 Unauthorized</h1>
You need a valid user and password to access this content.
</body></html>

Anyone?

Most helpful comment

You're configuration is wrong. It should be:

"test_settings" : {
    "default" : {
      "username": "admin",
      "access_key": "secret"
   }
},

https://github.com/nightwatchjs/nightwatch/blob/master/bin/nightwatch.json#L48

All 5 comments

The way I deal with this issue is by setting credentials in the launch URL. So something like

"test_settings": {
    "default": {
      "launch_url": "https://username:[email protected]",
      ...
    }
}

You're configuration is wrong. It should be:

"test_settings" : {
    "default" : {
      "username": "admin",
      "access_key": "secret"
   }
},

https://github.com/nightwatchjs/nightwatch/blob/master/bin/nightwatch.json#L48

@mattpardee How do you handle this in the url if the password contains spaces? i.e "test test test". Idk why but it is not working for me when specifying in test settings.

@aamorozov does "test%20test%20test" work? not sure how otherwise

@mattpardee Yep, it worked, thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danielbentov picture danielbentov  路  4Comments

davecranwell picture davecranwell  路  3Comments

dakebl picture dakebl  路  4Comments

bushev picture bushev  路  4Comments

Pieras2 picture Pieras2  路  3Comments