在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. iOS 5的文件存储策略应对

    苹果在iOS 5系统时,对app的文件存储提出了新的要求.从它的guildline来看,是推荐开发者尽量把app生成的文件放在Caches目录下的.原文如下: Only user-generated ...

  2. ios大文件存储

    I am using Erica Sadun's method of Asynchronous Downloads (link here for the project file: download) ...

  3. Oracle 11gR2 RAC 单网卡 转 双网卡绑定 配置步骤

    之前写过一篇双网卡绑定的文章,如下: Oracle RAC 与 网卡绑定 http://blog.csdn.net/tianlesoftware/article/details/6189639 Ora ...

  4. 一次lenovo a390t刷机体验

    今天一朋友说自己的联想a390t手机有时候打着打着电话就没声音了,手机好像死机了一样,以前用着挺好的没什么毛病. 因为以前用刷机精灵刷过几个android手机,感觉挺简单的,只要找好对应的rom点击两 ...

  5. String转Map的工具类

    借鉴代码 public class StringToMapUtil { public static Map<String, String> getValue(String param) { ...

  6. Android之——流量管理程序演示样例

    转载请注明出处:http://blog.csdn.net/l1028386804/article/details/47680811 眼下.市面上有非常多管理手机流量的软件,能够让用户实时获取到自己手机 ...

  7. UVA - 10895 Matrix Transpose

    UVA - 10895 Matrix Transpose Time Limit:3000MS   Memory Limit:Unknown   64bit IO Format:%lld & % ...

  8. linux 之体验(JDK7+Tomcat7+MySQL5.5)部署环境

    ---------------------------------------------------------------------------------------------------- ...

  9. vue 父子通信过程

    1.概述 每个 Vue 实例都实现了事件接口,即: 使用 $on(eventName) 监听事件 使用 $emit(eventName, optionalPayload) 触发事件 2.示例一(未传递 ...

  10. c# out ref

    out 关键字会导致参数通过引用来传递.这与 ref 关键字类似,不同之处在于 ref 要求变量必须在传递之前进行初始化.若要使用 out 参数,方法定义和调用方法都必须显式使用 out 关键字.例如 ...