Trm
Trm

Reputation: 479

Selenium Chrome instance with profile won't load site

I'm trying to fetch a site while using my profile as per instructions from this post. It successfully launches Chrome instance, but then it just stops and crashes after short amount of time raising below error:

selenium.common.exceptions.WebDriverException: Message: unknown error: 
Chrome failed to start: crashed
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 6.1 SP1 x86_64)

It works fine if I don't use any profile argument though, so I am not sure where's the issue. My code:

def ChromeTest():
    options = webdriver.ChromeOptions()
    options.add_argument(
        "user-data-dir=C:\\Users\\myuser\\AppData\\Local\\Google\\Chrome\\User Data")
    driver = webdriver.Chrome(executable_path="C:\\Users\\chromedriver.exe", chrome_options=options))
    site = "http://www.google.com"
    driver.get(site)

Upvotes: 1

Views: 3405

Answers (2)

Bar Margalit
Bar Margalit

Reputation: 38

Might be an old issue by now but I have come across this issue myself and got here, so for future reference:
It seems there's an issue with starting a selenium webdriver with chrome while an existing chrome window is open.
That was my problem: Webdriver didn't proceed to execute the rest of the test, while in the back I had another chrome window open. After I closed that open window, the test worked perfectly.
The issue has been reported though closed: https://bugs.chromium.org/p/chromedriver/issues/detail?id=1123
Best solution: either close existing chrome tab by testing, or do the tests in VM so no interruptions.

Upvotes: 1

thankyouSO
thankyouSO

Reputation: 98

Yes, as Bar Margalit pointed out, closing the existing chrome tab works but doesn't fully solve the problem. Especially if you want to use more than one Chrome Profile at the same time, you will run into the same problem again. What you can do though is move all relevant Chrome Profile folders to a different location (and change the directory in your code accordingly). It is pretty simple, I have answered the same question here:

Cannot open two Google Chrome instances with different profiles using selenium web driver for Chrome in Python

I hope this works for you.

Upvotes: 1

Related Questions