zoukankan      html  css  js  c++  java
  • Selenium python+chrome/firefox报错Message: Can not connect to the Service chromedriver

    1、执行

    >>> from selenium.webdriver import Chrome

    #添加path后执行

    >>> driver = Chrome()

    或>>> from selenium.webdriver import Chrome

    #驱动位置驱动

    >>> Chrome(executable_path='/usr/local/bin/chromedriver')

    报错:

    Traceback (most recent call last):

      File "<stdin>", line 1, in <module>

      File "/Users/cdtanghui3/Library/Python/2.7/lib/python/site-packages/selenium/webdriver/chrome/webdriver.py", line 62, in __init__

        self.service.start()

      File "/Users/cdtanghui3/Library/Python/2.7/lib/python/site-packages/selenium/webdriver/common/service.py", line 92, in start

        raise WebDriverException("Can not connect to the Service %s" % self.path)

    selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service chromedriver

    解决办法:加hosts:127.0.0.1 localhost

    $ vi /etc/hosts

    添加127.0.0.1 localhosts

    执行:

    >>> from selenium.webdriver import Chrome

    >>> Chrome(executable_path='/usr/local/bin/chromedriver')

    打开chrome浏览器成功

  • 相关阅读:
    5.4、获取对象信息
    5.3、继承和多态
    JS基础-组成
    js定时器
    js 原型链,继承,闭包,内存,泄露
    flex 布局
    点击导出table表格
    图片利用 new Image()预加载原理 和懒加载的实现原理
    js控制style样式
    自定义指令的用法
  • 原文地址:https://www.cnblogs.com/Tanwheey/p/12838379.html
Copyright © 2011-2022 走看看