在centos中使用无头chrome报以下错误

selenium.common.exceptions.WebDriverException: Message: unknown error: DevToolsActivePort file doesn't exist

解决办法

禁用sandbox

from selenium.webdriver.chrome.options import Optionsfrom selenium import webdriverchrome_options = Options()#加上下面两行,解决报错chrome_options.add_argument('--no-sandbox')

 chrome_options.add_argument('--disable-dev-shm-usage')

chrome_options.add_argument('window-size=1920x3000') #指定浏览器分辨率chrome_options.add_argument('--disable-gpu') #谷歌文档提到需要加上这个属性来规避bugchrome_options.add_argument('--hide-scrollbars') #隐藏滚动条, 应对一些特殊页面chrome_options.add_argument('blink-settings=imagesEnabled=false') #不加载图片, 提升速度chrome_options.add_argument('--headless') #浏览器不提供可视化页面. linux下如果系统不支持可视化不加这条会启动失败# chrome_options.binary_location = r"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" #手动指定使用的浏览器位置

driver=webdriver.Chrome(chrome_options=chrome_options)#executable_path驱动路径driver.get('http://www.baidu.com')print(driver.page_source)

成功运行chromedriver

转载于:https://www.cnblogs.com/z-x-y/p/9507467.html

selenium WebDriverException: Message: unknown error: DevToolsActivePort file doesnt exist相关推荐

  1. 解决selenium报错--unknown error: DevToolsActivePort file doesn‘t exist

    早上在linux下用selenium启动Chrome时出现问题: 报错: Traceback (most recent call last):File "get2.py", lin ...

  2. 迁移selenium脚本迁移后出现unknown error: DevToolsActivePort file doesn‘t exis

    迁移selenium脚本到其他服务器执行时出现以下错误: File "/data/app/jenkins/workspace/check-page/.venv/lib/python3.7/s ...

  3. 已解决selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary

    已解决selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary ...

  4. 解决问题 WebDriverException: Message: unknown error: cannot find Chrome binary

    通过jenkins来执行RobotFramework的脚本, 在执行机命令行中运行是完全OK的, 而通过jenkins执行相应的命令就提示下面的错误: 单项预订 =================== ...

  5. selenium:Message: unknown error : session deleted because of page crash

    问题描述 使用 Python selenium 写的代码,在服务器上运行报错: Message: unknown error : session deleted because of page cra ...

  6. selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary

    遇到了上面这个问题 有两种可能 没有chromedriver 没有找到chrome 对于第一种:用下面的这种方法 [解决方案]Selenium打开网站却显示空白 对于第二种,可以看下下面的东西. st ...

  7. 【错误归纳】selenium.common.exceptions.WebDriverException: Message: unknown error

    出现如上错误,一些解决方案: chrome_options.add_argument('--headless') 或者是: chrome_options.add_argument('--no-sand ...

  8. 解决selenium.common.exceptions.WebDriverException: Message: unknown error: call function result missin

    (Session info: chrome=73.0.3683.103)(Driver info: chromedriver=2.30.477700 (0057494ad8732195794a7b32 ...

  9. 【报错】unknown error: DevToolsActivePort file doesn‘t exis

    场景 在使用selenium 突然有天报错了,如题所示,代码如下: from selenium import webdriver from selenium.webdriver.chrome.opti ...

最新文章

  1. TX2安装中文输入法
  2. Webpack 4 api 了解与使用
  3. 区块链死亡项目列表小程序:死亡硬币
  4. noip2016 组合数问题
  5. 形似棺材的“抗震救生床”,你会要吗?
  6. python编程小知识_分享Python开发中要注意的十个小贴士
  7. Java JDK 10会有什么期望
  8. hbase-1.3.2安装
  9. Soul递交IPO招股书:腾讯为第一大股东,依然处于亏损状态
  10. 需要用sq语句 修改大批量用户的密码_网站文章seo优化及修改已收录文章建议
  11. ORACLE 两个表或两个结果集的数据对比常用的函数
  12. 一种结合实例和语义分割从田间图像中识别咖啡叶病虫害的深度学习方法
  13. 马克思知识点总结(二)
  14. spring--事务原理
  15. 软件测试缺陷报告分析,测试报告中的缺陷分析和测试结论应该怎么写?
  16. Compass实战 站内搜索
  17. IE浏览器被挟持怎么办,打不开正确网页被挟持到固定网页
  18. journey、voyage、trip、tour、travel的用法区别
  19. 如何批量修改拼多多价格?基于按键精灵实现--拼多多改价精灵
  20. 卸载Resharper

热门文章

  1. 哈希表(HashMap)分析及实现(JAVA)
  2. 项目支出数据产生过程
  3. 各类web服务器 http access log获取用户和代理ip
  4. Json在线格式化站点
  5. .Net WEB打印需要设置的内容和方法
  6. python __file__怎么实现_python lockfile(文件锁)
  7. dice系数 交叉熵_语义分割中的损失函数
  8. java编写存钱_用Java编写一个简单的存款
  9. 无法打开文件“opencv_world410d.obj”
  10. calibrate_cameras算子说明