【问题标题】:pytest-selenium: pytest_selenium_capture_debug hook is not fired on test failurepytest-selenium:pytest_selenium_capture_debug 钩子不会在测试失败时触发
【发布时间】:2021-11-13 15:30:47
【问题描述】:

我使用 pytest 和 selenium 为 Web 应用程序进行 e2e 测试。一切都很好,但是我花了一天时间搜索网络却无法弄清楚一件事。

我无法让pytest_selenium_capture_debug 工作。我把它放在测试源根目录下的conftest.py 中。测试在 docker 容器中运行。 Firefox 使用xvfb-run 运行。我录制屏幕视频,如果测试失败,想将其复制到主机。

我使用python 3.6.11,这些库版本是

pytest==6.2.4
pytest-base-url==1.4.2
pytest-helpers-namespace==2021.4.29
pytest-html==3.1.1
pytest-lazy-fixture==0.6.3
pytest-metadata==1.11.0
pytest-repeat==0.9.1
pytest-selenium==2.0.1
pytest-variables==1.9.0
selenium==3.141.0

【问题讨论】:

    标签: python selenium pytest hook


    【解决方案1】:

    使用custom_selenium 夹具引起的问题。要使所有pytest-selenium 挂钩正常工作,必须使用pytest-selenium 定义的selenium 固定装置,如下所示。

    @pytest.fixture
    def logged_in_selenium(selenium):
        ...
    

    【讨论】:

      猜你喜欢
      • 2019-09-14
      • 1970-01-01
      • 2021-02-06
      • 2014-10-07
      • 1970-01-01
      • 2016-11-02
      • 2016-06-02
      • 1970-01-01
      • 2011-09-08
      相关资源
      最近更新 更多