Python Windows Authentication username and password is not working

Solution 1:

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:[email protected]/basic_auth")

Solution 2:

    def test_1_authentication(self):
        self.driver.get("https://the-internet.herokuapp.com/basic_auth")
        shell = win32com.client.Dispatch("WScript.Shell")
        shell.Sendkeys("admin")
        time.sleep(3)
        shell.Sendkeys("{TAB}")
        time.sleep(3)
        shell.Sendkeys("admin")
        time.sleep(3)
        shell.Sendkeys("{ENTER}")
        time.sleep(3)

Above code is also properly worked :)