我正在设置我的系统(Windows 7 Pro 64位,通过Anaconda使用Python 3.5),以通过硒使用Firefox,以遵循《用Python测试驱动开发》一书. Python不断抛出错误WebDriverException:’geckodriver.exe’可执行文件需要放在PAT...

我正在设置我的系统(Windows 7 Pro 64位,通过Anaconda使用Python 3.5),以通过硒使用Firefox,以遵循《用Python测试驱动开发》一书. Python不断抛出错误WebDriverException:’geckodriver.exe’可执行文件需要放在PATH中.即使我已将系统路径设置为指向geckodriver的文件夹(并重新启动了3次).
如果我将python / selenium指向geckodriver.exe的确切位置,则会出现以下错误
OSError: [WinError 216] This version of %1 is not compatible with the
version of Windows you're running. Check your computer's system information
to see whether you need a x86 (32-bit) or x64 (64-bit) version of the program,
and then contact the software publisher
此时,我不确定错误版本%1是否与firefox是错误版本(我尝试过64位和32位),壁虎驱动程序,硒或其他完全错误有关.
解决方法:
如果您拥有64位计算机,请确保下载了GeckoDriver for win-64 bit.现在,将粘贴的下载的GeckoDriver可执行文件复制粘贴到“脚本”文件夹中(此文件夹位于系统中安装python的根文件夹中).现在在环境变量中设置python根文件夹和’Script’文件夹的路径
C:\..Python; //path of python root folder
C:\..Python\Scripts; //path of python 'Script' folder
不要忘记重启系统以使更改生效&试试这个示例代码
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://google.com")
本文标题为:如何正确设置Windows7以将Selenium与Firefox结合使用[带Python的TDD]?


基础教程推荐
- windows环境下python虚拟环境的创建,使用和断网移植 2023-09-03
- django+nginx+python3 生产环境部署 2023-09-04
- Python_多进程 2023-09-03
- 在Python中模拟子进程调用 2023-11-15
- 如何修复AttributeError:在Google Cloud Interactive Shell中运行python时,“模块”对象没有属性“客户端” 2023-11-11
- python-从子进程实时打印标准输出 2023-11-13
- python-如何将空参数传递给Popen(shell = False)? 2023-11-10
- Python实现RLE格式与PNG格式互转 2022-09-02
- Pytorch关于Dataset 的数据处理 2023-08-04
- PyTorch搭建CNN实现风速预测 2023-08-11