1

In this question an answer is given on how to handle authentication popup with Selenium WebDriver using Java. Now, can this be used also for python? It looks like the python driver has no class UserAndPassword like the Java pendant has.

Here is what I have tried:

    wait = WebDriverWait(driver, 10)
    alert = wait.until(ExpectedConditions.alertIsPresent())
    alert.authenticateUsing(UserAndPassword("user","passwd"))
Community
  • 1
  • 1
Alex
  • 41,580
  • 88
  • 260
  • 469

1 Answers1

0

Indeed there is no such class in python selenium library, but you can easly navigate to given alert and input user and password using other means.

wait = WebDriverWait(driver, 10)
alert = wait.until(ExpectedConditions.alert_is_present())
alert = driver.switch_to_alert()
alert.send_keys('username')
alert.send_keys(Keys.TAB)
alert.send_keys('password')
alert.accept()

This will work on standard authentication, if it is custom made one you will probably have tinker with it abit.

Tomasz Plaskota
  • 1,329
  • 12
  • 23
  • 1
    No does not work. I suppose the authentication box I am presented is not an 'alert', but something else. So, an alert is never present. But a box is. See http://stackoverflow.com/questions/36789858/how-to-fill-fields-in-a-popup-when-opening-a-sharepoint-website-with-selenium-us for an example how this box looks like... – Alex Jul 05 '16 at 15:22