basic auth window pop up

138 views
Skip to first unread message

Vladimir Djordjevic

unread,
Mar 10, 2025, 10:41:21 AMMar 10
to Selenium Users
Hi @all

My name is Vlada and I work as junior automation engineer..
I m trying to handle basic auth window pop up with my python selenium script. I m using pyautogui to send username and password  (and to press enter) to that window  and that works fine, but instead of proceed to homepage this window reopens prompting the username and pass again. Also when I try to enter manually username and pass everything works fine  - I m logged in, so it seems tthat browser (Chrome and Firefox) or maybe Windows ( Im on Windows 11) are blocking authentication through the script. I tried to turn off windows defender and firewall as well as some options in browser settings but nothing helps. I also tried to set up a proxy ( to include a header with "Basic auth" as described in this blog https://jimevansmusic.blogspot.com/2019/05/handling-authentication-requests-part2.html but it doesnot work for me. I would highly apprecieate if someone could help me to solve this problem. Thank you in advance.
My script is looking like this ( this is justa an experimental code - username and pass as well as url are just placeholders)

from selenium import webdriver
import time
import pyautogui
from selenium.webdriver.chrome.options import Options

chrome_options = Options()

chrome_options.add_argument("--incognito")
chrome_options.add_argument("--disable-save-password-bubble")
chrome_options.add_argument("--disable-blink-features=AutomationControlled")
chrome_options.add_argument("--start-maximized")  # Pokreće prozor u maksimalnom režimu
chrome_options.add_argument("--disable-blink-features=AutomationControlled")
chrome_options.add_argument("--disable-infobars")  # Onemogući infobar sa automatskim porukama
chrome_options.add_argument("--disable-extensions")  # Onemogući ekstenzije
chrome_options.add_argument("--disable-popup-blocking")  # Onemogući blokiranje pop-up prozora
chrome_options.add_argument("--disable-extensions")

driver = webdriver.Chrome(options=chrome_options)



# Set up WebDriver
# driver = webdriver.Chrome(options=options)
driver.get("exapmle.com")  # or the URL that causes the pop-up
time.sleep(5)
# Handle Windows pop-up using pyautogui

time.sleep(2)  # Wait for the pop-up to appear
pyautogui.write('username')  # Type username
time.sleep(2)
pyautogui.press('tab')
time.sleep(2)
pyautogui.write('pass')  # Type password
time.sleep(2)
pyautogui.press('enter')  # Submit  'IPH3gbpacw
time.sleep(3)

Corey Goldberg

unread,
Mar 13, 2025, 9:39:13 AMMar 13
to seleniu...@googlegroups.com

I m trying to handle basic auth window pop up with my python selenium script. I m using pyautogui to send username and password  (and to press enter) to that window

Don't use pyautogui for this.

The proper way to handle Basic Authentication in modern Selenium (version 4+) is to use BiDi network features to pass the credentials in HTTP headers.

Here is an example in Python. See the code in `test_basic_auth`:



Reply all
Reply to author
Forward
0 new messages