使用 python 使用 gecko 驱动程序
Working with gecko driver using python
如何使用 python 设置 Firefox gecko 驱动程序的路径?
因为使用 Java 设置路径非常容易,但我在 Pycharm?
中使用 python 设置壁虎路径时遇到了问题
请帮忙
这是您问题的答案:
在 PyCharm 中,要使用 Selenium 3.4.3、GeckoDriver v0.17.0、Mozilla Firefox 53.0 和 Python 3.6.1,您可以考虑下载 GeckoDriver 并将其保存在您的系统中,然后通过executable_path
.
配置GeckoDriver的绝对路径
It is to be noted that the current Selenium-Python binding is unstable with GeckoDriver and looks to be Architecture specific. You can find the github discussion and merge here. So you may additionally need to pass the absolute path of the firefox binary as firefox_binary
argument while initializing the webdriver
这是一个通过 GeckoDriver v0.17.0 打开 Mozilla Firefox 53.0 的示例代码块:
from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = FirefoxBinary('C:\Program Files\Mozilla Firefox\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary, executable_path="C:\your_directory\geckodriver.exe")
driver.get('https://whosebug.com')
让我知道这个回答你的问题。
您可以简单地解压 geckodriver 并将 geckodriver.exe 放入 C:\PythonXX 就可以了
只需使用
driver = webdriver.Firefox()
注意:您需要 Firefox > 48 的兼容版本、geckodriver(最好有最新版本)和 selenium > 3.3
如何使用 python 设置 Firefox gecko 驱动程序的路径?
因为使用 Java 设置路径非常容易,但我在 Pycharm?
中使用 python 设置壁虎路径时遇到了问题请帮忙
这是您问题的答案:
在 PyCharm 中,要使用 Selenium 3.4.3、GeckoDriver v0.17.0、Mozilla Firefox 53.0 和 Python 3.6.1,您可以考虑下载 GeckoDriver 并将其保存在您的系统中,然后通过executable_path
.
It is to be noted that the current Selenium-Python binding is unstable with GeckoDriver and looks to be Architecture specific. You can find the github discussion and merge here. So you may additionally need to pass the absolute path of the firefox binary as
firefox_binary
argument while initializing thewebdriver
这是一个通过 GeckoDriver v0.17.0 打开 Mozilla Firefox 53.0 的示例代码块:
from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = FirefoxBinary('C:\Program Files\Mozilla Firefox\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary, executable_path="C:\your_directory\geckodriver.exe")
driver.get('https://whosebug.com')
让我知道这个回答你的问题。
您可以简单地解压 geckodriver 并将 geckodriver.exe 放入 C:\PythonXX 就可以了
只需使用
driver = webdriver.Firefox()
注意:您需要 Firefox > 48 的兼容版本、geckodriver(最好有最新版本)和 selenium > 3.3