Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium - User prompt of type promptUserAndPass is not supported

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!

like image 303
cooper Avatar asked May 25 '19 09:05

cooper


2 Answers

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)
like image 100
elinnore Avatar answered Sep 19 '22 08:09

elinnore


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")
like image 34
elead1 Avatar answered Sep 19 '22 08:09

elead1