Selenium-不支持提示用户类型提示的用户提示 [英] Selenium - User prompt of type promptUserAndPass is not supported

查看:202
本文介绍了Selenium-不支持提示用户类型提示的用户提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很长时间以来,我一直在使用python机器人来完成一些工作任务.除其他外,该机器人还必须通过身份验证窗口.

For a long time I've been using a python bot to do some work task. Among others things, the bot has to pass an authentication window.

以下在python程序中的代码如下:

The code of this in the python program is the following:

driver = webdriver.Firefox(firefox_profile=profile)
...
driver.get('https://example.com')
driver.switch_to.alert.send_keys('123456' + Keys.TAB + '123456')
driver.switch_to.alert.accept()

但是昨天它抛出了这个错误:

But yesterday it throwed this error:

selenium.common.exceptions.WebDriverException:消息:用户提示 不支持输入提示用户和通行证

selenium.common.exceptions.WebDriverException: Message: User prompt of type promptUserAndPass is not supported

我一直在搜索,但是我什至找不到关于这种异常以及如何处理此问题的结果.

I've been googling but I even don't find results about this kind of exception and how to deal with this problem.

有什么想法吗?

提前谢谢!

推荐答案

目前看来,任何驱动程序都不支持HTTPAuth对话框.
Firefox实施了一种变通办法,该变通办法在67.0中不再起作用. 似乎由于缺少规范,他们现在无法开始添加对HTTP身份验证提示的支持.

It seems that HTTPAuth dialogs are not supported by any drivers at the moment.
Firefox implemented an workaround which does not work anymore in 67.0. It appears they cannot start adding support for the HTTP authentication prompt right now, due to missing specifications.

https://bugzilla.mozilla.org/show_bug.cgi?id=1556026

https://bugzilla.mozilla.org/show_bug.cgi?id=1556307

https://github.com/w3c/webdriver/issues/385

我已经设法解决此问题,方法是使用其他名称安装Firefox 66.0,然后在调用FirefoxDriver时提及它的位置,就像@ elead1一样.

I've managed to workaround this problem by installing Firefox 66.0 under a different name and then mentioning its location when calling the FirefoxDriver, like @elead1 did.

from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver import Firefox

path = FirefoxBinary("/path/to/Firefox2/firefox-bin")
browser = Firefox(firefox_binary=path)

这篇关于Selenium-不支持提示用户类型提示的用户提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆