UPDATE: Using seleniumbase worked, per comment.
After the chromedriver updates with version 115, it's suggested to use the manager to handle the driver/executable installation like this:
driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
But I'm on VPN, which blocks this connection. How do I manually specify the path to both the chromedriver and chrome testing executable?
And if anyone can link me to the documentation for this, I would be more than happy to read it, but I have not even been able to find it.
EDIT: I tried this (I tried setting absolute paths and that didn't help):
service = Service(executable_path='chromedriver.exe')
options = webdriver.ChromeOptions()
options.binary_location = 'chrome.exe'
driver = webdriver.Chrome(service=service, options=options)
and got this:
Traceback (most recent call last):
File "C:\Program Files\Python38\lib\code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "C:\Users\p3000151\AppData\Local\pypoetry\Cache\virtualenvs\splunk_on_call-xABy5ETk-py3.8\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 49, in __init__
super().__init__(
File "C:\Users\p3000151\AppData\Local\pypoetry\Cache\virtualenvs\splunk_on_call-xABy5ETk-py3.8\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 54, in __init__
super().__init__(
File "C:\Users\p3000151\AppData\Local\pypoetry\Cache\virtualenvs\splunk_on_call-xABy5ETk-py3.8\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 206, in __init__
self.start_session(capabilities)
File "C:\Users\p3000151\AppData\Local\pypoetry\Cache\virtualenvs\splunk_on_call-xABy5ETk-py3.8\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 291, in start_session
response = self.execute(Command.NEW_SESSION, caps)["value"]
File "C:\Users\p3000151\AppData\Local\pypoetry\Cache\virtualenvs\splunk_on_call-xABy5ETk-py3.8\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 346, in execute
self.error_handler.check_response(response)
File "C:\Users\p3000151\AppData\Local\pypoetry\Cache\virtualenvs\splunk_on_call-xABy5ETk-py3.8\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to create Chrome process.
Stacktrace:
GetHandleVerifier [0x00007FF7D0DD6F92+54962]
(No symbol) [0x00007FF7D0D44FF2]
(No symbol) [0x00007FF7D0BFA6AB]
(No symbol) [0x00007FF7D0C2702A]
(No symbol) [0x00007FF7D0C24E5E]
(No symbol) [0x00007FF7D0C63A5B]
(No symbol) [0x00007FF7D0C634D0]
(No symbol) [0x00007FF7D0C5B6E3]
(No symbol) [0x00007FF7D0C303E1]
(No symbol) [0x00007FF7D0C31624]
GetHandleVerifier [0x00007FF7D1129782+3538594]
GetHandleVerifier [0x00007FF7D117F520+3890240]
GetHandleVerifier [0x00007FF7D11779DF+3858687]
GetHandleVerifier [0x00007FF7D0E735B6+695510]
(No symbol) [0x00007FF7D0D50048]
(No symbol) [0x00007FF7D0D4C144]
(No symbol) [0x00007FF7D0D4C272]
(No symbol) [0x00007FF7D0D3C633]
BaseThreadInitThunk [0x00007FFDC2167614+20]
RtlUserThreadStart [0x00007FFDC29426B1+33]
the log looks like this:
[1695134982.210][INFO]: Starting ChromeDriver 118.0.5993.3 (7a51b9ea23325fae1ec1dad5a02c67c2240d7b11-refs/branch-heads/5993@{#7}) on port 60693
[1695134982.210][INFO]: Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
[1695134982.677][INFO]: [86d49340f523de943fea4c30087657ec] COMMAND InitSession {
"capabilities": {
"alwaysMatch": {
"browserName": "chrome",
"goog:chromeOptions": {
"args": [ ],
"binary": "C:\\Users\\p3000151\\PycharmProjects\\SPLUNK ON CALL\\chrome.exe",
"extensions": [ ]
},
"pageLoadStrategy": "normal"
},
"firstMatch": [ {
} ]
}
}
[1695134982.679][INFO]: Populating Preferences file: {
"alternate_error_pages": {
"enabled": false
},
"autofill": {
"enabled": false
},
"browser": {
"check_default_browser": false
},
"distribution": {
"import_bookmarks": false,
"import_history": false,
"import_search_engine": false,
"make_chrome_default_for_user": false,
"skip_first_run_ui": true
},
"dns_prefetching": {
"enabled": false
},
"profile": {
"content_settings": {
"pattern_pairs": {
"https://*,*": {
"media-stream": {
"audio": "Default",
"video": "Default"
}
}
}
},
"default_content_setting_values": {
"geolocation": 1
},
"default_content_settings": {
"geolocation": 1,
"mouselock": 1,
"notifications": 1,
"popups": 1,
"ppapi-broker": 1
},
"password_manager_enabled": false
},
"safebrowsing": {
"enabled": false
},
"search": {
"suggest_enabled": false
},
"translate": {
"enabled": false
}
}
[1695134982.680][INFO]: Populating Local State file: {
"background_mode": {
"enabled": false
},
"ssl": {
"rev_checking": {
"enabled": false
}
}
}
[1695134982.686][INFO]: Launching chrome: "C:\Users\p3000151\PycharmProjects\SPLUNK ON CALL\chrome.exe" --allow-pre-commit-input --disable-background-networking --disable-backgrounding-occluded-windows --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-automation --enable-logging --log-level=0 --no-first-run --no-service-autorun --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir="C:\Users\p3000151\AppData\Local\Temp\scoped_dir4444_743592924" data:,
[1695134982.714][INFO]: [86d49340f523de943fea4c30087657ec] RESPONSE InitSession ERROR unknown error: Failed to create Chrome process.
I'm using the win64 executables. Could this have anything to do with my VPN?
Here's how you can specify the driver path and the browser binary location:
(The .exe
is for Windows. If on Mac / Linux, it won't be there.)
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
service = Service(executable_path='./chromedriver.exe')
options = webdriver.ChromeOptions()
options.binary_location = "PATH_TO_BINARY.exe"
driver = webdriver.Chrome(service=service, options=options)
# ...
driver.quit()
You might also be able to use the SeleniumBase driver manager to get around the issue, which may avoid slowness that occurs when downloading drivers over a VPN.
(pip install seleniumbase
, and run with python
):
from seleniumbase import Driver
driver = Driver(browser="chrome")
driver.get("https://www.google.com")
driver.quit()