简体   繁体   English

如何使用python处理Selenium WebDriver的身份验证弹出窗口?

[英]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.

相关问题 如何使用 Selenium Webdriver 处理浏览器身份验证弹出窗口 - How to Handle Browser Authentication popup using Selenium Webdriver 如何使用 Java 处理 Selenium WebDriver 的身份验证弹出窗口 - How to handle authentication popup with Selenium WebDriver using Java 如何使用 Java 使用 Selenium WebDriver 在 Chrome 中处理身份验证弹出窗口 - How to handle authentication popup in Chrome with Selenium WebDriver using Java 如何使用Java中的Selenium WebDriver处理身份验证弹出窗口 - How to handle authentication popup with Selenium WebDriver in Java 如何使用python(加上java)处理selenium中的windows身份验证弹出窗口 - How to handle windows authentication popup in selenium using python(plus java) 如何使用Java通过Selenium WebDriver处理fancybox弹出窗口 - How to handle fancybox popup through Selenium WebDriver using Java 如何使用Selenium WebDriver处理“使用Google登录”弹出窗口 - How to handle 'Log in with Google' popup window using Selenium WebDriver 如何使用Selenium WebDriver处理Excel下载弹出窗口 - How to handle Excel download popup using Selenium WebDriver 如何使用Selenium WebDriver处理叠加/弹出窗口 - How to handle overlay/popup window using selenium webdriver 如何使用带有Java的Selenium WebDriver处理日历弹出窗口? - How to handle calendar popup using Selenium WebDriver with Java?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM