我正在尝试将硒与python3
一起使用。我做了一个很小的脚本,只是打开了firefox浏览器,此后导致google.ch
。
现在,我的问题是python2
可以正常工作,但是如果我尝试使用python3
运行脚本,firefox浏览器会打开,但不会打开google.ch
。
我真的很想用python3
来完成整个工作。有人知道问题可能在哪里吗?
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
# Replace below path with the absolute path
# to chromedriver in your computer
driver = webdriver.Firefox(executable_path='/usr/local/bin/geckodriver')
driver.get("https://google.ch")
wait = WebDriverWait(driver, 600)sudo rm
注意:我用pip3
错误回溯:
Traceback (most recent call last):
File "/home/pi/python_projects/SitzwacheTool/read.py", line 11, in <module>
driver = webdriver.Firefox(executable_path='/usr/local/bin/geckodriver')
File "/home/pi/.local/lib/python3.5/site-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
keep_alive=True)
File "/home/pi/.local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "/home/pi/.local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/home/pi/.local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/home/pi/.local/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: connection refused