I am trying to access a website, However to access the website first I need to enter username and password, After that full website will get open. When I try to send username an
driver.get("http://UserName:Password@Example.com"); should do the trick if the site uses basic authentication.
Special note: if you have @ in your password, don't forget to replace that bad boy by a %40
In case your authentication server requires username with domain like "domainuser" you need to add double slash / to the url:
//localdomain\user:password@example.com
EDIT:
Chrome 59 has removed support for https://user:password@example.com URLs.
You can use the following method to handle it in IE as of selenium 3.4
WebDriverWait wait = new WebDriverWait(driver, 10);
Alert alert = wait.until(ExpectedConditions.alertIsPresent());
alert.authenticateUsing(new UserAndPassword(username, password));
There is way of handling this using Chrome extension. More explanation can be found here
OR
Downgrade your chrome version to <59