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

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

解决办法

禁用sandbox

from selenium.webdriver.chrome.options import Options
from selenium import webdriver
chrome_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') #谷歌文档提到需要加上这个属性来规避bug
chrome_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

selenium WebDriverException: Message: unknown error: DevToolsActivePort file doesnt exist的更多相关文章

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

    解决centos7下 selenium报错--unknown error: DevToolsActivePort file doesn't exist 早上在linux下用selenium启动Chro ...

  2. selenium.common.exceptions.WebDriverException: Message: unknown Error: cannot find Chrome binary

    使用Chrome浏览器时,经常会遇到以下报错:浏览器没有调用起来 selenium.common.exceptions.WebDriverException: Message: unknown Err ...

  3. Python3 Selenium自动化测试赋值出现:WebDriverException: Message: unknown error: call function result missing 'value'

    Python3 Selenium自动化测试赋值出现:WebDriverException: Message: unknown error: call function result missing ' ...

  4. robotframework执行用例时,报错selenium.common.exceptions.WebDriverException: Message: unknown error: cannot get automation extension from unknown error: page could not be found: chrome-extension://aapnijgdinl

    在用robotframework编写移动端测试用例(用chrome浏览器模拟手机浏览器),执行用例时, 报错selenium.common.exceptions.WebDriverException: ...

  5. WebDriverException: Message: unknown error: Chrome failed to start: crashed

    the last answer WebDriverException: Message: unknown error: Chrome failed to start: crashed

  6. python unknown error: DevToolsActivePort file doesn't exist 问题解决

    解决方案: from selenium.webdriver.chrome.options import Options chrome_options = Options() chrome_option ...

  7. 关于执行webdriver.Chrome; 报错WebDriverException: Message: unknown error: Element is not clickable at point (1085, 103)

    from selenium import webdriverfrom time import sleep dr = webdriver.Chrome() dr.get("http://pj1 ...

  8. RF运行脚本报错:WebDriverException: Message: unknown error: call function result missing

    原因:浏览器驱动与浏览器版本不对应

  9. 不能聚焦元素问题 WebDriverException: Message: unknown error: cannot focus element

    上周碰到了 Unable to locate element,即“无法定位元素”,后靠两行代码解决: wait = ui.WebDriverWait(driver,5) wait.until(lamb ...

随机推荐

  1. ASIHTTPRequest 类库在iOS 7.0中,会有一些报错警告,需要稍作修改

    1. if ([inputStream streamStatus] == NSStreamEventErrorOccurred) { 修改成: if ([inputStream streamStatu ...

  2. Fresco的使用及注意事项

    Fresco的使用及注意事项 时间 2016-10-17 18:32:12 DevWiki's Blog 原文  http://blog.devwiki.net/index.php/2016/10/1 ...

  3. Flutter开发记录part1

    (1)AppBar:automaticallyImplyLeading//是否带返回leading箭头 (2)非route路由页面跳转 :Navigator.of(context).push(Mate ...

  4. 【重点突破】——Drag&Drop拖动与释放

    一.引言 在学习HTML5新特性的时候,学到了Drag&Drop这两种拖放API,这里根据拖动的是“源对象”还是“目标对象”做两个小练习,主要是为了理解与应用HTML5为拖放行为提供的7个事件 ...

  5. 性能测试脚本开发(C&C#&Java)

    一.C语言实现及相关问题解决 LR:C函数-功能描述 LR:C函数-适用范围 LR:C函数-头信息传递 LR:C函数-字符串编码转换 lr_convert_string_encoding(" ...

  6. OCP学习基本知识点总结

     下面是我总结的OCP教程的知识点.以备參考之用. 1, What's Oracle Server? ·         It's a database management system that ...

  7. Asp 解析 XML并分页显示

    Asp 解析 XML并分页显示 Asp 解析 XML并分页显示,演示样例源代码例如以下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Tr ...

  8. OJ刷题---ASCII码排序

    题目要求: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbGluaGFpeXVuX3l0ZHg=/font/5a6L5L2T/fontsize/400/f ...

  9. p90x 涵盖了全部方式的健身方式美国经典训练DVD

    http://baike.baidu.com/view/2602721.htm  p90x是美国经典训练DVD, 涵盖了全部方式的健身方式13张Beachbody P90X DVD全集,90天魔鬼训练 ...

  10. Android加载网络图片学习过程

    好多应用,像我们公司的<乘友>还有其他的<飞鸽><陌陌><啪啪>这些,几乎每一款应用都需要加载网络图片,那ToYueXinShangWan,这是比须熟练 ...