How to Handle basic Authentication window?
Like our facebook page www.facebook.com/ankprotraining
Handling Basic Authentication Window in selenium webdriver:
This is a Basic authentication window used to accept the username and password with browser alert popup
We will get this popup when we try access a server resource which requires authentication
This popup appears the moment we enter the url in the address bar
Methods of handling authentication window in selenium webdriver :
We can handle basic authentication in 4 ways
1. Passing user name and password along with the url
driver.get(“http://UserName:[email protected]”)
2. alert.setAuthenticationCredentials method.
driver.switchTo().alert().setAuthenticationCredentials(“username”,”password”)
3. Using SendKeys
alert.sendKeys( "username" + Keys.Tab + "password" + Keys.Tab); alert.accept();
4. We can use the third party automation tools like AutoIt or Sikuli for sending the keys to this window.
The approach to handle authentication window popup may be different in each browser, try any one of mentioned method.
In case your authentication server requires username with domain like "domainuser" you need to add double slash to the url:
//domainname\user:[email protected]
If your username or password is having @ symbol then replace it with %40
Possible Interview Questions on selenium webdriver on handling basic authentication window:
How to handle basic authentication windows?