M
M
Maxim Kiselyov2019-01-22 18:31:31
Python
Maxim Kiselyov, 2019-01-22 18:31:31

How to run chrome using Selenium WebDriver with my profile?

Here is my code:

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


options = Options()
options.add_argument('user-data-dir=C:\\Users\\kisel\\AppData\\Local\\Google\\Chrome\\User Data')

chromedriver = r"C:\chromedriver.exe"

driver = webdriver.Chrome(executable_path=chromedriver,# На этой строке ещё всё норм
                          options = options)    # На этой уже крашится

driver.get("https://www.любой_сайт.com")    # Здесь уже не работает

# Я обновил python, selenium, пробовал разные версии chromedriver и ничего.
# Браузер запускается с моим профилем, но уже не идёт дальше по скрипту

HERE IS THE ERROR:
Traceback (most recent call last):
  File "C:\Users\kisel\OneDrive\Рабочий стол\main.py", line 14, in <module>
    driver = webdriver.Chrome(executable_path=chromedriver, options = options)
  File "C:\Users\kisel\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
  File "C:\Users\kisel\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "C:\Users\kisel\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\kisel\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\kisel\AppData\Local\Programs\Python\Python37-32\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:\Program Files (x86)\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.17763 x86_64)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan, 2019-01-23
@Iv_and_S

"with my profile" - and if you specified settings there that were not implemented at all in chromedriver .. Tell me
which profile options do you need to work with?
Read here: Does Selenium work with Chrome webdriver to replace content settings? - there is a 100% working example in my answer, for disabling JS in chromedriver settings.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question