Selenium - User prompt of type promptUserAndPass is not supported

这一生的挚爱 提交于 2020-08-21 06:35:31

问题


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.

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: 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.

Any ideas?

Thanks in advance!


回答1:


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

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)



回答2:


I don't have enough rep to comment and I know this isn't "solving" the problem, but I was able to work around this problem by using the Firefox ESR.

You can install the ESR parallel to your main Firefox installation, and then specify which binary the FirefoxDriver will use:

driver = webdriver.Firefox(firefox_profile=profile, firefox_binary="/path/to/esr/binary")


来源:https://stackoverflow.com/questions/56303422/selenium-user-prompt-of-type-promptuserandpass-is-not-supported

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!