TA的每日心情 | 开心 2015-4-13 19:27 |
---|
签到天数: 1 天 连续签到: 1 天 [LV.1]测试小兵
|
代码:
#-*-coding:utf-8-*-
from selenium import webdriver
from time import sleep
driver = webdriver.Chrome()
driver.get('https://www.baidu.com')
driver.find_element_by_name('wd').send_keys('selenium')
driver.find_element_by_id('su').click()
sleep(3)
driver.close()
谷歌浏览器版本:最新的62驱动是V2.33
运行脚本后报错:D:\Python\Python36\python.exe D:/PyCharm/webtest.pyTraceback (most recent call last): File "D:\Python\Python36\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 67, in __init__ desired_capabilities=desired_capabilities) File "D:\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 87, in __init__ self.start_session(desired_capabilities, browser_profile) File "D:\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 141, in start_session 'desiredCapabilities': desired_capabilities, File "D:\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 199, in execute response = self.command_executor.execute(driver_command, params) File "D:\Python\Python36\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 395, in execute return self._request(command_info[0], url, body=data) File "D:\Python\Python36\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 426, in _request resp = self._conn.getresponse() File "D:\Python\Python36\lib\http\client.py", line 1331, in getresponse response.begin() File "D:\Python\Python36\lib\http\client.py", line 297, in begin version, status, reason = self._read_status() File "D:\Python\Python36\lib\http\client.py", line 258, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") File "D:\Python\Python36\lib\socket.py", line 586, in readinto return self._sock.recv_into(b)ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。During handling of the above exception, another exception occurred:Traceback (most recent call last): File "D:\Python\Python36\lib\urllib\request.py", line 1318, in do_open encode_chunked=req.has_header('Transfer-encoding')) File "D:\Python\Python36\lib\http\client.py", line 1239, in request self._send_request(method, url, body, headers, encode_chunked) File "D:\Python\Python36\lib\http\client.py", line 1285, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "D:\Python\Python36\lib\http\client.py", line 1234, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "D:\Python\Python36\lib\http\client.py", line 1026, in _send_output self.send(msg) File "D:\Python\Python36\lib\http\client.py", line 964, in send self.connect() File "D:\Python\Python36\lib\http\client.py", line 936, in connect (self.host,self.port), self.timeout, self.source_address) File "D:\Python\Python36\lib\socket.py", line 722, in create_connection raise err File "D:\Python\Python36\lib\socket.py", line 713, in create_connection sock.connect(sa)ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。During handling of the above exception, another exception occurred:Traceback (most recent call last): File "D:/PyCharm/webtest.py", line 5, in <module> driver = webdriver.Chrome() File "D:\Python\Python36\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 69, in __init__ self.quit() File "D:\Python\Python36\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 88, in quit self.service.stop() File "D:\Python\Python36\lib\site-packages\selenium\webdriver\chrome\service.py", line 111, in stop url_request.urlopen("http://127.0.0.1:%d/shutdown" % self.port) File "D:\Python\Python36\lib\urllib\request.py", line 223, in urlopen return opener.open(url, data, timeout) File "D:\Python\Python36\lib\urllib\request.py", line 526, in open response = self._open(req, data) File "D:\Python\Python36\lib\urllib\request.py", line 544, in _open '_open', req) File "D:\Python\Python36\lib\urllib\request.py", line 504, in _call_chain result = func(*args) File "D:\Python\Python36\lib\urllib\request.py", line 1346, in http_open return self.do_open(http.client.HTTPConnection, req) File "D:\Python\Python36\lib\urllib\request.py", line 1320, in do_open raise URLError(err)urllib.error.URLError: <urlopen error [WinError 10061] 由于目标计算机积极拒绝,无法连接。>Process finished with exit code 1
|
|