selenium中的常见报错

来源:互联网 发布:合同翻译软件 编辑:程序博客网 时间:2024/05/17 00:49

1.

ImportError: cannot import name ‘webdriver'
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH
selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH.

Please see https://sites.google.com/a/chromium.org/chromedriver/home原因是由于没有将chromedriver.exe放在/usr/bin/目录里

在导入是要注意:

这里写图片描述

第四行
driver = webdriver.Chrome(r"/usr/bin/chromedriver”) 
中应该是chromedrive.exe的路径

2.

======================================================================ERROR: test_search_in_python_org (__main__.mytest)----------------------------------------------------------------------Traceback (most recent call last):  File "mystyle.py", line 12, in test_search_in_python_org    driver.get("www.baidu.com")  File "/Users/zhangjia/anaconda/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 309, in get    self.execute(Command.GET, {'url': url})  File "/Users/zhangjia/anaconda/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 297, in execute    self.error_handler.check_response(response)  File "/Users/zhangjia/anaconda/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response    raise exception_class(message, screen, stacktrace)selenium.common.exceptions.WebDriverException: Message: unknown error: unhandled inspector error: {"code":-32000,"message":"Cannot navigate to invalid URL"}  (Session info: chrome=61.0.3163.100)  (Driver info: chromedriver=2.32.498537 (cb2f855cbc7b82e20387eaf9a43f6b99b6105061),platform=Mac OS X 10.12.6 x86_64)----------------------------------------------------------------------Ran 1 test in 1.896sFAILED (errors=1)

错误原因:

这里写图片描述

第十二行应该是http://www.baidu.com不是www.baidu.com

原创粉丝点击