Monday, September 28, 2020

Cypress: How to handle browser-based authentication pop up dialog in Cypress

Five years ago I have written a blog on how to handle browser-based authentication for selenium webdriver.

 

Now it is for cypress.


Cypress has come with a very easy solution.


A very simple syntax to handle the browser-based authentication,

If we have a username and password and the URL then the cypress command will be 


cy.visit(app_URL, {auth:{username:appUserName, password: appPassword}})


For example, we have

username : abc

password : abc123

URL : xyz.com


Then cypress command will be


cy.visit('https://www.xyz.com', {

auth: {

        username: abc,

        password: abc123

      }

})

 

There is an alternative way that cypress suggested,


cy.visit(http://username:password@domainName.com)


Note that we have a special character colon “:” between username and password.


For the above example,


Cypress command will be,


cy.visit('https://abc:abc123@www.xyz.com')


That’s all for now. We will discuss more on cypress in my future post.

Thank you. 

Happy automation testing with Cypress!

No comments:

Post a Comment

Cypress: How to handle browser-based authentication pop up dialog in Cypress

Five years ago I have written a blog on how to handle browser-based authentication for selenium webdriver.   Now it is for cypress. Cypress...