[英]TimeoutError: [WinError 10060] :
I am trying to connect to my firefox browser with selenium.我正在尝试使用 selenium 连接到我的 firefox 浏览器。
#Initialise Firefox
print("here")
locationofDriver = "C:/Users/barry/OneDrive/Documents/Webdriver/"
print("here2")
driver = webdriver.Firefox(locationofDriver)
print("here3")
Yet I get two errors:然而我得到两个错误:
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
And:和:
urllib3.exceptions.ProtocolError: ('Connection aborted.', TimeoutError(10060, 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond', None, 10060, None))
The Output from the print statements:打印语句中的 Output:
here
here2
I launched Firefox manually to see if their was an issue, however it is perfectly functional The web-driver is in the correct place.我手动启动了 Firefox 以查看它们是否有问题,但是它功能完美 Web 驱动程序位于正确的位置。
Any help appreciated.任何帮助表示赞赏。
Instead providing only the location of the WebDriver executable you need to provide the absolute path of the ChromeDriver / GeckoDriver along with the extension ie .exe
.而是只提供WebDriver可执行文件的位置,您需要提供ChromeDriver / GeckoDriver的绝对路径以及扩展名,即
.exe
。 So your effective code block will be:因此,您的有效代码块将是:
For ChromeDriver :对于ChromeDriver :
locationofDriver = r'C:/Users/barry/OneDrive/Documents/Webdriver/chromedriver.exe'
For GeckoDriver :对于GeckoDriver :
locationofDriver = r'C:/Users/barry/OneDrive/Documents/Webdriver/geckodriver.exe'
Finally, you can pass the key executable_path
along the value as follows:最后,您可以将key
executable_path
沿值传递,如下所示:
driver = webdriver.Firefox(executable_path=locationofDriver)
try it:试试看:
locationofDriver = "<path to file>/geckodriver.exe"
Or add geckodriver.exe
to directory with working python file and then you can try:或者将
geckodriver.exe
添加到具有工作 python 文件的目录中,然后您可以尝试:
driver = webdriver.Firefox()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.