首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >尽管处于系统路径,Geckodriver仍未被识别

尽管处于系统路径,Geckodriver仍未被识别
EN

Stack Overflow用户
提问于 2020-03-29 02:14:07
回答 2查看 2.4K关注 0票数 1

摘要: Geckodriver似乎没有被识别,尽管它在系统路径中被精确设置

当前系统配置:

  • 操作系统: Windows 10;版本: 1909;OS构建: 18363.752;系统类型:64位OS Windows系统信息
  • 已安装的Microsoft可再发行运行时:vc_redist.x64.exe
  • 用户环境变量值:"C:\Users\PCUserName\AppData\Local\Programs\Python\Python38\Scripts\;C:\Users\PCUserName\AppData\Local\Programs\Python\Python38\;%IntelliJ IDEA Community %;C:程序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 Driver\;C:\开发\Selenium Resources\Selenium Drivers;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\Program \Microsoft VS Code\bin;“
  • 系统环境变量值:%path%;C:开发\Selenium Resources\Selenium驱动程序;C:\Program(X86)\通用Files\Oracle\Java\javapath;C:\Ruby26-x64\bin;C:\Program文件(x86)\Razer \bin;C:\Program\Razer SDK\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft \bin;C:\Program \Git\cmd;C:\ 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 Driver\;C:Development\Selenium Resources\Selenium Drivers\chromedriver.exe;C:\Development\Selenium Resources\Selenium Drivers\geckodriver.exe;“
  • 保存Selenium驱动程序的目录:C:\Development\Selenium Resources\Selenium Drivers 硒驱动程序目录
  • 安装火狐浏览器版本: 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

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

我已经尝试过什么了?:

  • 当我的配置文件config.json浏览器参数设置为:chrome时,验证使用以下命令执行Github项目是否执行得很好:
  • 在Google,Stackoverflow,Reddit上搜索了一个小时,并试图排除为什么这不起作用.:(

实际结果:执行时:pipenv从以下目录运行pytest:

EN

回答 2

Stack Overflow用户

发布于 2020-03-29 04:19:32

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

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

票数 1
EN

Stack Overflow用户

发布于 2020-03-29 02:59:02

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

代码语言:javascript
复制
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.
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60909396

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档