0

I need to access a web application which requires windows authentication. Is there any way I can bypass this windows authentication or is there any way to handle this.

Selenium webdriver version - selenium-java-3.6.0

Eclipse IDE for Java Developers Version: Oxygen.1 Release (4.7.1)

Browser - Chrome latest

Sanchit
  • 315
  • 2
  • 20
olive silva
  • 1
  • 2
  • 4

2 Answers2

1

Solution 1: Provide the Username and Password in the URL

WebDriver driver = new FirefoxDriver();
String baseUrl=”http://” + “USERNAME” + “:” + “PASSWORD” + “@” + “xyz.com”;
driver.get(baseUrl + “/”);

Solution 2: Use Robot Class to enter the User ID and Password in the authentication alert popup. This will only work if the Username field is in focus when the popup appears.

George
  • 53
  • 2
  • 3
  • 10
0

The Alert Method, authenticateUsing() lets you skip the Http Basic Authentication box.

WebDriverWait wait = new WebDriverWait(driver, 10);      
Alert alert = wait.until(ExpectedConditions.alertIsPresent());     
alert.authenticateUsing(new UserAndPassword(username, password));

OR

Selenium Java code:

driver.get("http://USERNMAE:PASSWORD@YOUR_URL");
halfer
  • 19,824
  • 17
  • 99
  • 186
Shubham Jain
  • 16,610
  • 15
  • 78
  • 125