我正在设置我的系统(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 @R_256_4045@ion
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位),壁虎驱动程序,硒或其他完全错误有关.
@H_502_12@解决方法:如果您拥有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")
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。