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浏览器成功

  • 相关阅读:
    测试管理工具
    测试用例--zy
    测试计划和测试用例
    测试用例
    软件测试基础
    异步任务 ---- django-celery
    图片验证码接口
    测试作业
    数据库原理
    HTTPS原理
  • 原文地址:https://www.cnblogs.com/Tanwheey/p/12838379.html
Copyright © 2011-2022 走看看