I want to use the URL to pass a HTTP Basic Authentication Check with Selenium WebDriver in Chrome. To open the site i use code like this:
from selenium import webdriver
from src.pom import settings
PATH = settings.chromedriver_path
driver = webdriver.Chrome(PATH)
driver.maximize_window()
driver.get('https://username:Ziel#0Fehler@www.google.com')
However this gives me selenium.common.exceptions.InvalidArgumentException: Message: invalid argument
If i remove the # or the: between the username and the HTTP Auth Password the error doesnt get thrown but I need this exact data for the HTTP Auth
Python 3:
import urllib.parse
password = 'Ziel#0Fehler'
password = urllib.parse.quote(password)
driver.get(f'https://username:{password}@www.google.com')
you have url encode password as it has special characters that have special meaning in url eg: #
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.