-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Description
What happened?
When setting a custom user-data-directory AND chromedriver binary path at the same time: I get:
Error initializing WebDriver: Message: session not created from unknown error: unable to discover open pages
When removing the line options.add_argument(f"--user-data-dir={user_data_directory}") it runs fine.
When running without the custom executable path as service = Service() instead of service = Service(executable_path=chromedriver_binary_path) it runs fine while using the custom user-data directory and selenium manager chromedriver.
For my use case I need to be able to set both user-data-directory AND the custom binary path, however it seems when using both something is breaking. Am I doing something wrong here? I've exhausted every possible solution I could come up with.
Tested in chrome headless shell + chromedriver 132.0.6834.83.
Same setup config works fine with chrome non headless + chromedriver 132.0.6834.83.
How can we reproduce the issue?
Following is a snippet of my code:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
chrome_binary_path = CC.get_chrome_binary_path(directory)
chromedriver_binary_path = CC.get_chromedriver_binary_path(directory)
user_data_directory = CC.get_user_data_directory()
# Initialize Chrome options
options = Options()
options.binary_location = chrome_binary_path
options.add_argument(f"--user-data-dir={user_data_directory}")
options.add_argument("--headless=new")
options.add_argument('--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36')
options.add_experimental_option("prefs", {
"download.default_directory": directory,
"download.directory_upgrade": True,
"download.prompt_for_download": False,
"credentials_enable_service": False,
"profile.password_manager_enabled": False
})
options.add_argument('--start-maximized')
options.add_argument('--disable-notifications')
options.add_argument("--disable-third-party-cookies")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--no-sandbox")
options.add_argument("--disable-extensions")
options.add_experimental_option("excludeSwitches", ["enable-automation", "enable-logging"])
options.add_experimental_option("useAutomationExtension", False)
options.add_argument('--log-level=3')
service = Service(executable_path=chromedriver_binary_path)
# Initialize WebDriver with the given options and service
driver = webdriver.Chrome(service=service, options=options)
driver.quitRelevant log output
Error initializing WebDriver: Message: session not created
from unknown error: unable to discover open pages
Stacktrace:
GetHandleVerifier [0x00007FF624A0FBE5+28741]
(No symbol) [0x00007FF624977890]
(No symbol) [0x00007FF624814FDA]
(No symbol) [0x00007FF624855BB8]
(No symbol) [0x00007FF624850069]
(No symbol) [0x00007FF62484B399]
(No symbol) [0x00007FF62489B17A]
(No symbol) [0x00007FF62489A7B0]
(No symbol) [0x00007FF62488FCB3]
(No symbol) [0x00007FF624859FB3]
(No symbol) [0x00007FF62485B331]
GetHandleVerifier [0x00007FF624D4A73D+3414941]
GetHandleVerifier [0x00007FF624D5E64A+3496618]
GetHandleVerifier [0x00007FF624D5413D+3454365]
GetHandleVerifier [0x00007FF624AD848B+850155]
(No symbol) [0x00007FF6249837FF]
(No symbol) [0x00007FF62497F0C4]
(No symbol) [0x00007FF62497F25D]
(No symbol) [0x00007FF62496E079]
BaseThreadInitThunk [0x00007FFAC68B259D+29]
RtlUserThreadStart [0x00007FFAC7F4AF38+40]Operating System
Windows 11
Selenium version
selenium-4.27.1
What are the browser(s) and version(s) where you see this issue?
chrome and chrome headless shell 132.0.6834.83
What are the browser driver(s) and version(s) where you see this issue?
chromedriver 132.0.6834.83
Are you using Selenium Grid?
No response