I am trying to open Chrome webdriver through Selenium and I'm getting an error when initializing it. The error I'm receiving:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "F:\WinPython\python-3.6.7.amd64\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 81, in __init__
desired_capabilities=desired_capabilities)
File "F:\WinPython\python-3.6.7.amd64\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "F:\WinPython\python-3.6.7.amd64\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "F:\WinPython\python-3.6.7.amd64\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "F:\WinPython\python-3.6.7.amd64\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location C:\Users\MyName\AppData\Local\Microsoft\AppV\Client\Integration\some-ever-changing-hash\Root\VFS\ProgramFilesX86\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387),platform=Windows NT 10.0.14393 x86_64)
I've been searching for different solutions. I've tried manually specifying path to Chrome.exe, I've added snippets like add_argument("--disable-dev-shm-usage")
and options.add_argument("--no-sandbox")
as well as using separate user-data-dir. Current code can be seen below
import os
from selenium import webdriver
###auto-find chrome path
def chrome_path_auto():
for root, dirs, files in os.walk('C:/Users'):
for name in files:
if name == 'chrome.exe':
return os.path.abspath(os.path.join(root, name))
options = webdriver.ChromeOptions()
chrome_driver_binary = "H:/My Documents/PYTHON/selenium_script/chromedriver/chromedriver.exe"
options.binary_location = chrome_path_auto()
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--user-data-dir=H:\\My Documents\\PYTHON\\selenium_script\\UserDataDir")
options.add_argument("--disable-extensions")
options.add_argument("--no-sandbox")
driver = webdriver.Chrome(chrome_driver_binary, chrome_options=options)
driver.get('https://python.org')
Version of Chrome is 71.0.3578.80, Chromedriver is 2.45, so it should be compatible. I've tried using older versions but then I get only part of the error: DevToolsActivePort file doesn't exist. It might be important to note that I am using a remote desktop that very recently changed OS from Windows 7 to Windows 10. On the old windows a very similar approach (using older versions of both Chrome and Chromedriver) was working. Did anyone encounter similar issue or can think of of alternative solutions?
If anything else is needed please tell me, I'll try to provide such info.
EDIT 1.
I have managed to fix the problem by simply moving whole Chrome installation from original folder
C:\Users\MyName\AppData\Local\Microsoft\AppV\Client\Integration\some-ever-changing-hash\Root\VFS\ProgramFilesX86\Google\Chrome\Application\chrome.exe
to the shared disk H:\Public\Chrome\Application
and then using binary_location. It might have to do something with the Root location of original folder and lack of admin rights.