Sunday, June 14, 2015

Selenium : How to handle browser based authentication using Selenium Webdriver

Couple of years ago, I got an issue about browser based authentication and I googled about it and found the resolution. In recent days I face the same problem. I forgot to fix and again googled and found lots of automated testers like me are facing the same problem. Now I decide to write a small post on it so that I can remember every time from my post and also I can help our automated testers.

A very simple syntax to handle the browser based authentication,

If we have username and password and the URL then requested URL will be,

http://username:password@domainName.com

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

For example, we have
username : abc
password : abc123
URL : xyz.com
then the requested URL for Selenium Webdriver command,
abc:abc123@xyz.com
So the Selenium Webdriver command to open application in a browser,

(C#)
driver.Navigate().GoToUrl("http://abc:abc123@xyz.com/");

(Java)
driver.get("http://abc:abc123@xyz.com/");

Thank you…..
Enjoy automated testing using Selenium Webdriver….!!!

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...