-1

I'm trying to handle authentication popup using Selenium Webdirve in Java. Here are the things I have tried :

[![Pop-up I am dealing with][1]][1]

//Selenium-WebDriver Java Code for entering Username & Password as below:
 driver.switchTo().alert().sendKeys("username" + Keys.TAB + "password");
 driver.switchTo().alert().accept();```
Using AutoIT :

Send("username{TAB}myPassword{ENTER}")```



Selenium-WebDriver Java Code for entering Username & Password as below:

driver.findElement(By.id("password")).sendKeys("myPassword");
driver.switchTo().alert().accept();
driver.switchTo().defaultContent();



I have used the above-mentioned methods but it doesn't work. Also , I am not getting any errors in console .


 [1]: https://i.stack.imgur.com/xSkbs.png
  • 1
    So the popup you are seeing is Basic authentication popup ? Can you share a snapshot to confirm it ? Also have you checked that you are waiting for enough time before sending AutoIt command to fill up the information ? – Sariq Shaikh Nov 26 '20 at 17:32
  • I think the pop-up you talking about it is an authentication popup. Authentication popup and Alert are 2 different things. And screenshot will be helpful. – KunLun Nov 26 '20 at 17:44
  • I am not able to add a screenshot over here .I tried but its not working :( – Just_curious_tester Nov 27 '20 at 05:56

1 Answers1

1

You should wait for the element first.

WebDriverWait wait = new WebDriverWait(webDriver, timeoutInSeconds);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("password")));

Checkout this question for more details

JMSalazarDev
  • 155
  • 6