0

I tried Using below code but not worked.

WebDriverWait wait = new WebDriverWait(driver, 2);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = driver.switchTo().alert();
alert.sendKeys("Uname" + Keys.TAB + "pwd"); 
alert.accept();

Image

2 Answers 2

1

Verify the popup present after the landing page loaded,if popup presents use getcurrenturl method and concatenate the username and password with the current url.

e.g., http://Username:Password@CurrentURL

0

Use the below code it may work

driver.get('https://example.com/')
driver.switchTo().alert().sendKeys("username" + Keys.TAB + "password");
driver.switchTo().alert().accept();
1
  • The above will work when the login is in basic url..but my authentication will come in after 1st page,the authentication url is dynamic based on search results
    – Sinu Reddy
    Commented Mar 8, 2019 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.