1

摘要: Geckodriver 似乎无法识别,尽管它已在 SYSTEM PATH 中准确设置

当前系统配置:

  • 操作系统:Windows 10;版本:1909;操作系统版本:18363.752;系统类型:64 位操作系统 Windows 系统信息

  • 已安装Microsoft Visual Studio 可再发行运行时:vc_redist.x64.exe

  • 用户环境变量值:“C:\Users\PCUserName\AppData\Local\Programs\Python\Python38\Scripts\;C:\Users\PCUserName\AppData\Local\Programs\Python\Python38\;%IntelliJ IDEA Community Edition% ;C:\Program Files\Java\jdk-13.0.1\bin;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;C:\Development\Selenium Resources\Selenium Drivers\geckodriver.exe;C:\Development\Selenium Resources\Selenium Drivers\chromedriver.exe;C:\Development\Selenium Resources\Selenium Drivers\;C:\Development\Selenium Resources\Selenium Drivers;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program文件\Git\cmd;C:\Program Files\Microsoft VS Code\bin;"

  • 系统环境变量值:“%path%;C:\Development\Selenium Resources\Selenium Drivers;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Ruby26-x64\bin;C: \Program Files (x86)\Razer Chroma SDK\bin;C:\Program Files\Razer Chroma SDK\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows \System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\Git\cmd;C:\Program Files\Java\jre1.8.0_221\bin\javaw.exe ;C:\Program Files\Java\jdk-12.0.2\bin;C:\Users\PCUserName\AppData\Local\Programs\Python\Python38;C:\Users\PCUserName\AppData\Local\Programs\Python\Python38 \Scripts;C:\Development\Selenium Resources\Selenium Drivers\;C:\Development\Selenium Resources\Selenium Drivers\chromedriver.exe;C:\Development\Selenium Resources\Selenium Drivers\geckodriver.exe;"

  • Selenium Driver 的保存目录:C:\Development\Selenium Resources\Selenium Drivers Selenium Drivers Directory

  • 安装的 Firefox 浏览器版本:74.0(64 位)

  • 安装的 Geckodriver 版本:geckodriver-v0.26.0-win64.zip 从这里:https ://github.com/mozilla/geckodriver/releases

  • Github 项目(最新):https ://github.com/cikent/Selenium-Projects/tree/master/Selenium-PythonProjects/python-webui-testing

目标/目标: 解决 Geckodriver 未被检测到的问题,因此我可以通过参考 Automation Panda 的以下指南继续使用 Selenium 和 Pytest 在 Python 中设置自动化框架:https ://blog.testproject.io/2019/07/16/read -config-files-in-python-selenium/

我已经尝试过什么?:

实际结果: 当我执行时:pipenv run python -m pytest从以下目录:C:\Development\Selenium-Projects\Selenium-PythonProjects\python-webui-testing,我得到: PowerShell Execution of Pytest & Output

4

2 回答 2

1

问题不在于 geckodriver 的路径。问题是在 Python 代码中找不到“Firefox”作为标记。

使用配置夹具将此导入添加到模块:“from selenium.webdriver import Firefox”。

于 2020-03-29T04:19:32.337 回答
0

我建议使用 webdriver_manager,这样您就不必处理所有这些问题。这很简单,如下所示。并且webdriver_manager将获得基于操作系统和架构的最新稳定驱动程序。

from selenium import webdriver
from webdriver_manager.firefox import GeckoDriverManager

driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
driver.get("https://www.google.com")
# continue using the driver as usual.
于 2020-03-29T02:59:02.663 回答