6
votes

I am using:

  • Selenium 4
  • python 3.7
  • Firefox webdriver

I need to verify the username and password for my current project. I've been working day and night for days and I can't solve this problem. I've found a few extension on the internet, but it's from '13 year and I guess that's why it doesn't work. You can also see other methods I've tried below.

But doesn't work, because Proxy Authentication is not working anymore due to the Selenium bug..

alert_popup = browser.switch_to_alert()
    alert_popup.send_keys(
        "{username}{tab}{password}{tab}".format(
            username=proxy_username, tab=Keys.TAB, password=proxy_password
    )
)
alert_popup.accept()

I wanted to create a profile and save the proxy information manually and start selenium with that profile. However, firefox does not allow user name and password to be entered manually.

2
Apparently selenium wire can do proxy auth, I'm not sure if I trust it though. - pguardiario
That's great! You might want to post an answer with how you did it for the next person. - pguardiario

2 Answers

5
votes

We solved this problem with a library for Selenium. Hopefully it benefits your business. Selenium Wire

https://github.com/wkeeling/selenium-wire

And thanks to @pguardiario for your help..

1
votes

To use proxies with auth in python selenium you can use seleniumwire.

Fistly, install it with pip install selenium-wire

Then import webdriver from seleniumwire instead selenium

Check the original Answer here

    from seleniumwire import webdriver
options = {
    'proxy': {
        'http': 'http://username:password@host:port', 
        'https': 'https://username:password@host:port',
        'no_proxy': 'localhost,127.0.0.1' # excludes
    }
}
browser = webdriver.Chrome(path_to_driver, seleniumwire_options=options)