It looks like our favorite friend https://github.com/cypress-io/cypress/issues/573 is back again and is no longer working.
Appears that chrome disabled disabling the blink feature that prevents this from working.
It's about time we permanently fixed this by adding a cy.visit(url, options) which will support an auth object with username + password.
When applied we'll need to automatically add the Authorization header to requests made to this origin at the network proxy layer.
Released in 2.0.0.
This is not working for me on Chrome 64 and 65 with cypress: 2.1.0.
Neither this one:
cy.visit('https://wile:[email protected]')
nor this:
cy.visit('https://www.acme.com/', {
auth: {
username: 'wile',
password: 'coyote'
}
})
@Alexintosh Same for me.
@brian-mann Could you please provide a link for the documentation regarding the feature?
Can anyone please suggest how to bypass or automate an HTTP authentication form for login using cypress?
this is working for me in ^3.0.0, and following the visit command docs.
I could not get it to work using a baseUrl so i tried using an env variable and override visit instead wich seems to work fine on chrome and electron.
index.js:
switch (configuration) {
case 'development': {
config.env.baseURL = 'localhost:4200';
}
case 'test': {
config.env.baseURL = 'https://example.com';
}
}
commands.js:
Cypress.Commands.overwrite('visit', (orig, url, options) => {
const URL = Cypress.env('baseURL') + url;
const auth = {
username : 'user',
password : 'pass'
}
if (options) {
options.auth = auth;
} else {
options = {
auth
}
}
return orig(URL, options);
})
Edit: fixed missing return. Thanks @brian-mann
@saschahauke you need to return orig else Cypress will not await the cy.visit command to complete.
@jennifer-shehane why did you reopen this issue in April... shouldn't it be closed?
@brian-mann Because there were 3 comments saying they still encountered this issue. Did not want it to be abandoned if there was an issue.
Most helpful comment
I could not get it to work using a baseUrl so i tried using an env variable and override visit instead wich seems to work fine on chrome and electron.
index.js:
commands.js:
Edit: fixed missing return. Thanks @brian-mann