[英]How to handle authentication popup with Selenium WebDriver using python?
In this question an answer is given on how to handle authentication popup with Selenium WebDriver using Java . 在这个问题中 ,给出了如何使用Java处理Selenium WebDriver的身份验证弹出窗口的答案。 Now, can this be used also for python? 现在,这可以用于python吗? It looks like the python driver has no class UserAndPassword
like the Java pendant has. 看起来python驱动程序没有类似Java挂件的类UserAndPassword
。
Here is what I have tried: 这是我尝试过的:
wait = WebDriverWait(driver, 10)
alert = wait.until(ExpectedConditions.alertIsPresent())
alert.authenticateUsing(UserAndPassword("user","passwd"))
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. 事实上,python selenium库中没有这样的类,但您可以使用其他方法轻松导航到给定警报并输入用户和密码。
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. 这将适用于标准身份验证,如果它是自定义的,您可能会修改它升级。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.