TA的每日心情 | 奋斗 2016-7-28 13:28 |
---|
签到天数: 10 天 连续签到: 1 天 [LV.3]测试连长
|
#coding=utf-8
from selenium import webdriver
driver = webdriver.Firefox()
#基本到这就走不下去了
driver.get("http://www.baidu.com")
driver.find_element_by_id("kw").send_keys("selenium2")
driver.find_element_by_id("su").click()
driver.quit()
特别简单的一段代码,但是每次执行的时候到打开firefox,打开浏览器后,浏览器就提示“firefox已停止工作”,关闭之后会报下面这个错,搜了很多方法,都不好用,比如加profile参数(>>> myprofile=webdriver.FirefoxProfile\ (r"C:\Users\yaowenyue\AppData\Roaming\Mozilla\Firefox\Profiles\ju9xf7p4.default")
>>> myBrowser=webdriver.Firefox(myprofile)),向各位大神请教。
火狐版本是47
Traceback (most recent call last):
File "<pyshell#17>", line 1, in <module>
driver=webdriver.Firefox()
File "F:\Python\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 85, in __init__
keep_alive=True)
File "F:\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 90, in __init__
self.start_session(desired_capabilities, browser_profile)
File "F:\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 177, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
File "F:\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 234, in execute
response = self.command_executor.execute(driver_command, params)
File "F:\Python\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 401, in execute
return self._request(command_info[0], url, body=data)
File "F:\Python\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 432, in _request
resp = self._conn.getresponse()
File "F:\Python\lib\http\client.py", line 1174, in getresponse
response.begin()
File "F:\Python\lib\http\client.py", line 282, in begin
version, status, reason = self._read_status()
File "F:\Python\lib\http\client.py", line 243, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "F:\Python\lib\socket.py", line 575, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。
|
|