【发布时间】:2017-03-09 22:12:31
【问题描述】:
我有这个代码
#!/usr/bin/env python
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
import time
driver = webdriver.Chrome()
并且错误出现在最后一行:driver = webdriver.Chrome() 它是这样说的:
Traceback (most recent call last):
File "/Users/Edison/Desktop/untitled folder/huamai_jacket1.py", line 9, in <module>
driver = webdriver.Chrome()
File "/Users/Edison/anaconda2/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 61, in __init__
log_path=service_log_path)
File "/Users/Edison/anaconda2/lib/python2.7/site-packages/selenium/webdriver/chrome/service.py", line 42, in __init__
start_error_message="Please see https://sites.google.com/a/chromium.org/chromedriver/home")
File "/Users/Edison/anaconda2/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 42, in __init__
self.port = utils.free_port()
File "/Users/Edison/anaconda2/lib/python2.7/site-packages/selenium/webdriver/common/utils.py", line 36, in free_port
free_socket.bind(('0.0.0.0', 0))
File "/Users/Edison/anaconda2/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 49] Can't assign requested address
Exception AttributeError: "'Service' object has no attribute 'log_file'" in <bound method Service.__del__ of <selenium.webdriver.chrome.service.Service object at 0x1049a93d0>> ignored
[Finished in 0.1s with exit code 1]
[shell_cmd: python -u "/Users/Edison/Desktop/untitled folder/huamai_jacket1.py"]
[dir: /Users/Edison/Desktop/untitled folder]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
发生在今天早上,事情发生在这之后,有时当我访问甚至像 google.com 这样的网站时,ERR_ADDRESS_INVALID 页面经常出现,我需要不断刷新才能将页面返回到常规站点。
这是因为 driver.Chrome() 不包含 Chromedriver 位置的 PATH 吗?不过,我在今天前一周使用了我的脚本,一切都很完美。 请帮忙:(
【问题讨论】:
标签: python google-chrome selenium selenium-webdriver selenium-chromedriver