从Chrome位置C:\ .. \ Chrome \ Application \ chrome.exe开始的进程不再运行,因此ChromeDriver假定Chrome已崩溃

时间:2018-08-24 17:38:00

标签: python selenium google-chrome selenium-webdriver selenium-chromedriver

Chrome版本:68.0.3440.106
Chrome网络驱动程序版本:ChromeDriver 2.41.578737
Python版本:Python 3.5.2

我用python编写这段代码:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys


o = webdriver.ChromeOptions()
o.add_argument("disable-extensions");
o.add_argument("--start-maximized");
driver = webdriver.Chrome(executable_path=r"chromedriver.exe",options=o)
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()

几秒钟后,chrome打开,并显示以下错误:


直到我关闭chrome并得到此异常,什么都没有发生:

    Traceback (most recent call last):
  File ".../game.py", line 8, in <module>
    driver = webdriver.Chrome(executable_path=r"chromedriver.exe",options=o)
  File "...\Python\Python35-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 75, in __init__
    desired_capabilities=desired_capabilities)
  File "...\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 156, in __init__
    self.start_session(capabilities, browser_profile)
  File "...\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 251, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "...\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 320, in execute
    self.error_handler.check_response(response)
  File "...\Python\Python35-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: exited normally
  (unknown error: unable to discover open pages)
  (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.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 10.0.17134 x86_64)

3 个答案:

答案 0 :(得分:0)

使用正确的参数禁用扩展名:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
o = Options()
#o.add_argument("--disable-extensions"); #here
o.add_experimental_option("useAutomationExtension", false); #you can try this as well
o.add_argument("--start-maximized");
driver = webdriver.Chrome(executable_path=r"chromedriver.exe",chrome_options=o)
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()

答案 1 :(得分:0)

此错误消息...

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited normally
  (unknown error: unable to discover open pages)
  (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.)

...表示 ChromeDriver 无法启动/产生新的 WebBrowser ,即 Chrome浏览器会话。

您的主要问题似乎是 chrome 二进制文件(即 chrome.exe )和关联的文件在以下默认位置不再可用:

C:\Program Files (x86)\Google\Chrome\Application\

可能的原因是:


其他注意事项

  • Chrome ChromeDriver 位于所需位置。
  • Chrome ChromeDriver 对非root用户(非管理员)具有可执行权限。
  • 升级到当前水平Version 3.14.0
  • 通过您的 IDE
  • 清理您的项目工作区重建您的项目,并且仅具有必需的依赖项。
  • (仅适用于 WindowsOS )使用CCleaner工具清除执行 Test Suite 前后的所有操作系统琐事。
  • (仅仅LinuxOS Free Up and Release the Unused/Cached Memory in Ubuntu/Linux Mint在执行 Test Suite 之前和之后。
  • 如果您的基本 Web客户端版本过旧,请通过Revo Uninstaller进行卸载,并安装最新版本的 Web客户端。 li>
  • 进行系统重启
  • 非root用户用户的身份执行@Test
  • 在装有台式机的计算机上使用webdriver-manager start运行selenium服务器(不要使用远程会话启动selenium服务器)。

答案 2 :(得分:0)

今天我遇到了同样的麻烦,并且使用以下方法解决了问题:

$('#clearFormButton').click(function(){
    ResetForm();
    $('#hiddenJobId').val(@Session["jobid"]);
});