【问题标题】:Cannot run Firefox (geckodriver) properly from PyCharm python console无法从 PyCharm python 控制台正确运行 Firefox (geckodriver)
【发布时间】:2019-02-12 18:46:09
【问题描述】:

所以我在其中使用 PyCharm 2018.2.3、geckodriver 0.20、Firefox 63.0 和 Python 3.6.5 进行 Selenium 自动测试。

我尝试在 Python 控制台中运行驱动程序:

from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.accept_untrusted_certs = True
wd = webdriver.Firefox(executable_path="C:\\Users\\user\\geckodriver.exe", firefox_profile=profile)

所以 geckodriver 在新窗口中运行。然后我通常会写

url = "https://website-address.com/"
wd.get(url)

但这次我得到了消息:

Previous command is still running. Please wait or press Ctrl+C in console to interrupt.

然后在几分钟后 geckodriver 退出并在日志中显示这些消息:

Traceback (most recent call last):
  File "<input>", line 4, in <module>
  File "C:\Users\user\project\venv\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 170, in __init__
    keep_alive=True)
  File "C:\Users\user\project\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 156, in __init__
    self.start_session(capabilities, browser_profile)
  File "C:\Users\user\project\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 251, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\user\project\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 320, in execute
    self.error_handler.check_response(response)
  File "C:\Users\user\project\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: newSession

请帮助我了解发生了什么以及如何解决它。

【问题讨论】:

    标签: python selenium geckodriver


    【解决方案1】:

    我遇到了同样的问题,在我将 geckodriver 更新到 v0.21.0 后得到了修复

    【讨论】:

    • 感谢您的回答!我将 geckodriver 更新到 v0.21.0 并收到错误:ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine 这让我在一个月前降级了驱动程序。我还尝试了 v.0.19.1、v.0.20.0 和我在问题中提到的相同错误。 (另外我将 Selenium 升级到 v.3.14 只是为了确保一切都是最新的)。
    • 您好,抱歉耽搁了,您的防火墙似乎有问题,请检查:social.msdn.microsoft.com/Forums/es-ES/…。我在 linux 上运行我的测试,所以我没有看到任何类似的问题。
    【解决方案2】:

    所以我在 geckodriver github (https://github.com/mozilla/geckodriver/issues/1369) 上打开了一个问题,该问题已被开发人员关闭,我在另一个类似问题中得到了实际答案:https://github.com/mozilla/geckodriver/issues/1305 - 他们发布了新版本的 geckodriver解决了所有问题。

    附:我几乎可以肯定我的防火墙没有问题。

    【讨论】:

      猜你喜欢
      • 2015-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-06
      • 1970-01-01
      • 2017-06-23
      相关资源
      最近更新 更多