【问题标题】:Pycharm Selenium Geckodriver Path issue [duplicate]Pycharm Selenium Geckodriver路径问题[重复]
【发布时间】:2019-06-01 23:32:09
【问题描述】:

我已经尝试了其他帖子中的解决方案,但没有任何成功。

每次我尝试在 pycharm 中将 python 与 selenium WebDrive 一起使用时,我都会收到相同的错误,错误日志:

“selenium.common.exceptions.WebDriverException:消息:'geckodriver' 可执行文件需要在 PATH 中。我已经下载了 Geckodriver exe 文件并添加了指向系统变量的链接,但消息 没有改变。

谢谢

【问题讨论】:

标签: python selenium


【解决方案1】:

我在 Ubuntu Linux 上使用了 Selenium 和 python。 对于 selenium,我一直在使用 chrome 驱动程序。 以下代码我使用了很长时间。

chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--window-size=%s" % WINDOW_SIZE)
chrome_options.binary_location = CHROME_PATH
driver = webdriver.Chrome(executable_path="ChromDriver/chromedriver",chrome_options=chrome_options)

这里chrome_options.binary_location = CHROME_PATH是安装google chrome后chrome二进制路径所在的位置。就我而言,它是 /usr/bin/google-chrome 此外,executable_path="ChromDriver/chromedriver" 是 chromediver for selenium 的位置,它与源代码一起放在 ChromDriver 目录中。

【讨论】:

    猜你喜欢
    • 2017-03-12
    • 2019-12-14
    • 2020-09-20
    • 2011-05-10
    • 1970-01-01
    • 2017-12-09
    • 2011-08-29
    • 2022-11-22
    • 1970-01-01
    相关资源
    最近更新 更多