具有配置文件的Selenium Chrome实例无法加载网站 [英] Selenium Chrome instance with profile won't load site

查看:139
本文介绍了具有配置文件的Selenium Chrome实例无法加载网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据

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)

推荐答案

现在可能是个老问题了,但是我本人已经遇到了这个问题并来到了这里,以便将来参考:
在现有的chrome窗口打开的同时,使用chrome 启动带有chrome的Selenium Webdriver似乎存在问题.
那是我的问题:Webdriver没有继续执行其余的测试,而在后面,我又打开了一个chrome窗口.当我关闭打开的窗口后,测试正常进行.
尽管已报告问题,但已关闭:
https://bugs .chromium.org/p/chromedriver/issues/detail?id = 1123
最佳解决方案:要么通过测试关闭现有的chrome标签,要么在VM中进行测试,以免中断.

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.

这篇关于具有配置文件的Selenium Chrome实例无法加载网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆