Python Windows Authentication username and password is not working

0
0

I am trying to enter data in prompt (URL Given), below codes is giving me an error. Please help me out with these?

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
import time
driver
= webdriver.Firefox()
url
= "http://the-internet.herokuapp.com/basic_auth"
driver
.get(url)
time
.sleep(5)
alert
= driver.switch_to.alert
alert
.authenticate('admin','admin')
time
.sleep(4)
alert
.accept()

I have tried with:

ActionChains(driver).send_keys("admin").send_keys(Keys.TAB).send_keys("admin").perform()

This one is also not working.

  • You must to post comments
0
0

When you work with Selenium 3.4.0, geckodriver v0.18.0, Mozilla Firefox 53.0 through Python 3.6.1 you can bypass the Basic Authentication popup through embedding the username and password in the url itself as follows.

This solution opens the URL http://the-internet.herokuapp.com/basic_auth and authenticates with a valid username and password credentials.

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary
= FirefoxBinary('C:\\Program Files\\Mozilla Firefox\\firefox.exe')
driver
= webdriver.Firefox(firefox_binary=binary, executable_path="C:\\Utility\\BrowserDrivers\\geckodriver.exe")
driver
.get("http://admin:admin@the-internet.herokuapp.com/basic_auth")
  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website