2

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

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

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

例如:

//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 文件,但没有找到任何接近它的东西。

4

2 回答 2

0

很难过,但你不能。phpunit不允许,因为WebDriver 不允许

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

于 2013-11-07T05:50:29.450 回答
-1

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

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

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

于 2012-07-16T14:40:52.903 回答