问题描述
Ubuntu 18.x + selenium webdriver(Firefox)
面对一个怪异的问题,如果我将所有run
一起使用
Facing a weird problem, the following block works if I run
all of it together
from selenium import webdriver
url = 'https://indiamart.com'
driver = webdriver.Firefox()
driver.get(url)
driver.find_element_by_xpath(xpath).click()
我尝试过的每一个url
都在发生这种情况.
This is happening with every url
I have tried.
但是,如果我一次执行一行,它会给出
However if I execute one line at a time, it gives
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/media/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 326, in get
self.execute(Command.GET, {'url': url})
File "/media/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute
response = self.command_executor.execute(driver_command, params)
File "/media/lib/python3.6/site-packages/selenium/webdriver/remote/remote_connection.py", line 472, in execute
return self._request(command_info[0], url, body=data)
File "/media/lib/python3.6/site-packages/selenium/webdriver/remote/remote_connection.py", line 495, in _request
self._conn.request(method, parsed_url.path, body, headers)
File "/usr/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1065, in _send_output
self.send(chunk)
File "/usr/lib/python3.6/http/client.py", line 986, in send
self.sock.sendall(data)
BrokenPipeError: [Errno 32] Broken pipe
这是code
driver.get(url)
但是,如果我在Broken Pipe error
之后再次执行同一行,它将起作用并获得url
.
However if I execute the same line again after the Broken Pipe error
it works and gets the url
.
我很困惑.有人可以帮我吗?
I am very very confused. Can someone help me out.
谢谢
推荐答案
这是geckodriver最新版本v0.21.0与最新版本的硒v3.11相匹配的已知错误
This is a known bug of the latest build v0.21.0 of geckodriver matched with the latest version of selenium v3.11
要解决此错误,请执行以下任一操作:a)降级geckodriver 到v0.20.1或更早版本b)等待即将发布的selenium和/或geckodriver版本中的错误修正/缓解措施
To work around this bug either:a) downgrade geckodriver to v0.20.1 or earlier b) wait for the bugfix/mitigations be rolled out in the upcoming versions of selenium and/or geckodriver
此错误源于Keep-Alive功能v 0.21中新增的支持.但是,来自geckodriver的默认超时为0.21设置为5s,这特别短.
This bug originates from newly added support in v 0.21 of Keep-Alive feature. However, the default timeout from geckodriver in 0.21 is set to 5s, which is exceptionally short.
此错误已在此处进行了跟踪,以查找geckodriver和在此获取硒.
This bug is tracked here for geckodriver and here for selenium.
这篇关于Selenium Webdriver管道损坏,命令之间有间隔时出错?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!