【问题标题】:How can I get page status code using behat + mink with selenium driver?如何使用 behat + mink 和 selenium 驱动程序获取页面状态代码?
【发布时间】:2017-07-27 19:56:45
【问题描述】:

Selenium 不支持此代码

$statusCode = $this->getSession()->getStatusCode();

是否可以通过其他方式检查状态?

【问题讨论】:

    标签: selenium behat mink


    【解决方案1】:

    这不是 Selenium 的设计目的。他们的一位项目成员reply to request to implement this in Selenium said

    我们不会将此功能添加到 WebDriver API,因为它超出了我们当前的范围(模拟用户操作)。

    解决方案是使用另一个支持状态码的驱动程序,或者尝试实施一种可用的 hack(在other stack overflow questions asking the very same thing 中给出)。

    【讨论】:

      【解决方案2】:

      您可以使用Restler,这是一个支持使用 Behat 和 Guzzle 进行行为驱动 API 测试的微框架。

      例如(见:status_codes.feature):

      @restler
      Feature: HTTP Status Codes
      
        Scenario: I should be able to suppress status code 404
          When I request "/examples/_001_helloworld?suppress_response_codes=true"
          Then the response status code should be 200
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-04-18
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多