【问题标题】:phpunit selenium getting header information of the url openphpunit selenium 获取打开的 url 的标头信息
【发布时间】:2013-11-07 13:50:29
【问题描述】:

我正在使用phpunitselenium 为我的项目编写一些功能测试。 我正在寻找的是检索响应头的方式

有些网址没有 .js 扩展名,但返回 javascript 作为代码。

我要找的是用$this->open();函数打开的URL的头部信息(尤其是content-type

例如:

//if I do
$this->open('http://stackoverflow.com');
// or
$this->open('http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js')

// and then use some function like
$this->getResponseHeaders();
// returns me array of header information or
// some function just for content type
$this->getContentType();
// which return text/html or text/javascript

selenium 是否有任何方式提供此功能或获取详细信息的技巧或技巧。我浏览了 selenium 文档和 TestCase 文件,但没有找到任何接近它的东西。

【问题讨论】:

    标签: selenium header phpunit


    【解决方案1】:

    这很可悲,但你不能。它does not allowed by phpunit 因为it does not allowed by WebDriver

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

    【讨论】:

      【解决方案2】:

      如果我理解您的问题,您需要以下两个步骤:

      $this->open('http://stackoverflow.com');
      $htmltext = $this->getHtmlSource();
      

      然后你可以通过拆分htmltext来获取信息...

      【讨论】:

      • 基本上我想要的是response header 详细信息和content-type 信息
      猜你喜欢
      • 1970-01-01
      • 2016-04-21
      • 1970-01-01
      • 1970-01-01
      • 2018-10-29
      • 2018-11-09
      • 2019-10-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多