selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.41.578700 (2f1ed5f9343c13f73144538f15c00b370eda6706),platform=Linux 3.10.0-862.el7.x86_64 x86_64)
使用selenium webdriver调用Chrome发现一直报错
--no-sandbox
如果不加一直报错,下面是提供弹幕
#coding = utf-8
from selenium import webdriver
chrome_options= webdriver.ChromeOptions()
chrome_options.add_argument('--no-sandbox')#解决DevToolsActivePort文件不存在的报错
chrome_options.add_argument('window-size=1920x3000') #指定浏览器分辨率
chrome_options.add_argument('--disable-gpu') #谷歌文档提到需要加上这个属性来规避bug
chrome_options.add_argument('--hide-scrollbars') #隐藏滚动条, 应对一些特殊页面
chrome_options.add_argument('blink-settings=imagesEnabled=false') #不加载图片, 提升速度
chrome_options.add_argument('--headless') #浏览器不提供可视化页面. linux下如果系统不支持可视化不加这条会启动失败
browser = webdriver.Chrome("/root/note/Python/myTools/Scrapy/driver/chromedriver",chrome_options=chrome_options)
browser.get("https://www.baidu.com")
print(browser.page_source)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn't exist) (The process started from ch...
selenium 运行
chrome
driver
报错问题描述问题原因解决方法
Selenium:
WebDriver
Exception:
Chrome
fail
ed
to start:
crash
ed
as google-
chrome
is no longer runn
ing
so
Chrome
Driver
is as
sum
ing
that
Chrome
has
crash
ed
执行代码:
from selenium import
webdriver
browser=
webdriver
Dur
ing
handl
ing
of the above exception, another exception occurr
ed
:
Traceback (most recent call last):
File "/home/project/login_by_user.py", line 175, in open_client
driver
=
webdriver
.
Chrome
(const.
driver
_path_80,
chrome
_options=
chrome
_op
测试部分代码:
Chrome
Options
chrome
Options = new
Chrome
Options();
chrome
Options.addArguments("--start-maximiz
ed
");
WebDriver
driver
= new
Chrome
Driver
(
chrome
Options);
driver
.get("http://www.baidu.com");
System.out.println(
driver
from selenium import
webdriver
from selenium.
webdriver
.common.by import By
from selenium.
webdriver
.common.keys import Keys
from selenium.
webdriver
.support import expect
ed
_conditions as EC
from selen
selenium.common.exceptions.
WebDriver
Exception: Message: unknown error:
Chrome
fail
ed
to start: exit
ed
normally
(unknown error: Devtools port number fi...
已解决selenium.common.exceptions.
WebDriver
Exception: Message: unknown error:
Chrome
fail
ed
to start:
crash
ed
(
chrome
not reachable)
(The process start
ed
from
chrome
location C:\Users\Administrator\AppData\Local\Google\
Chrome
\Application\
chrome
.exe is no longe
处理这个问题的前提是已经安装好了
chrome
,以及对应的
chrome
driver
(The process start
ed
from
chrome
location /opt/google/
chrome
is no longer runn
ing
, so
Chrome
Driver
is as
sum
ing
that
Chrome
has
crash
ed
.)
处理方式:
该问题是因为在linux中python中selenium寻找
chrome
浏览器的默认地址为/opt/google/
chrome
,通
解决
webdriver
中报错。
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.
WebDriver
Exception: Message: unknown error:
Chrome
fail
ed
to start: exit
ed
abnormally
(unknown error: De...
最近在学习使用selenium的时候,遇到了一个新问题,以前使用的时候没有出现,这让我很困惑,但是在Google上也没有找到解决的方案,不断的测试,最后解决了。这里分享一下问题的解决方案,希望能够帮助到也被这个问题困惑到的Coder.
什么是 Selenium ?
自动化测试工具,支持多种浏览器
爬虫中主要用来解决 JavaS...