Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic Authentication Pop-up in cypress #31182

Open
yopemu opened this issue Feb 27, 2025 · 0 comments
Open

Basic Authentication Pop-up in cypress #31182

yopemu opened this issue Feb 27, 2025 · 0 comments

Comments

@yopemu
Copy link

yopemu commented Feb 27, 2025

Current behavior

I am currently writing a test that requires Basic Authentication. According to the documentation, it should be possible to handle the authentication if I include the auth object in the command or the credentials in the URL. Unfortunately this does not work and the pop-up is always displayed.

I have tried the following:

cy.visit('https://admin:[email protected]/basic_auth');

cy.visit('https://the-internet.herokuapp.com/basic_auth', { auth: { username: 'admin', password: 'admin' }, failOnStatusCode: false });

cy.visit('https://the-internet.herokuapp.com/basic_auth', { headers: { authorization: 'Basic YWRtaW46YWRtaW4=' }, failOnStatusCode: false });

None of these options worked and the browser always shows the pop-up or 401 - Unauthorized if “failOnStatusCode:false” is not set.

Image

Image

Desired behavior

With Cypress I should be able to handle basic authentication (as described in the documentation) so that I can log in to the website and test further functionality.

Test code to reproduce

cy.visit('https://admin:[email protected]/basic_auth');

cy.visit('https://the-internet.herokuapp.com/basic_auth', { auth: { username: 'admin', password: 'admin' }, failOnStatusCode: false });

cy.visit('https://the-internet.herokuapp.com/basic_auth', { headers: { authorization: 'Basic YWRtaW46YWRtaW4=' }, failOnStatusCode: false });

Cypress Version

14.1.0

Node version

v22.11.0

Operating System

Windows 11 Enterprise, Edge v133

Debug Logs

Other

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant