How to Submit HTTP authentication with Selenium python-binding webdriver

0 votes

I'm using Selenium python binding to setup an automation test for our web application. I'm facing a problem while testing the web on beta server because it requires HTTP authentication for an intranet username and password.

from selenium import webdriver

driver = webdriver.Firefox()
driver.get("https://somewebsite.com/")

I need to submit a username and a password for the popup dialog upon accessing a website.

Is there a better way to do this?

Sep 25, 2018 in Selenium by Christine
• 15,790 points
354 views

1 answer to this question.

0 votes

I have found a solution to this question:

from selenium import webdriver

profile = webdriver.FirefoxProfile()
profile.set_preference('network.http.phishy-userpass-length', 255)
driver = webdriver.Firefox(firefox_profile=profile)
driver.get("https://username:password@somewebsite.com/")

The FirefoxProfile part is to dismiss the confirmation dialog because by default Firefox will show a popup dialog to prevent pishing.

answered Sep 25, 2018 by Meci Matt
• 9,420 points

Related Questions In Selenium

0 votes
1 answer

How to handle notifications in Python with Selenium (Chrome WebDriver)

Below will help you: You can disable the ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
2,518 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,090 points
798 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
1,037 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
743 views
0 votes
1 answer