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:Password@ankpro.com”)
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:password@example.com
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?
On this page of the site you can watch the video online Selenium with Java 46 - How to Handle basic Authentication window with a duration of hours minute second in good quality, which was uploaded by the user Ankpro Training 30 July 2018, share the link with friends and acquaintances, this video has already been watched 3,231 times on youtube and it was liked by 16 viewers. Enjoy your viewing!