【问题标题】:How can I get headers request using codeception from browser (headless or not)如何使用浏览器的代码接收获取标头请求(无头或无头)
【发布时间】:2018-01-25 16:36:19
【问题描述】:

这个问题可以重复,但我找不到任何明确的答案。

我正在使用带有 crhome 驱动程序和 selenium 独立服务器的 Codecepting 框架。

我想获取特定 Url 的所有标头请求。

请查看图片enter image description here

我找到了一种使用 phantomjs 的解决方案,如下面的代码所示:

var page = require('webpage').create();

page.onResourceRequested = function(request) {

  console.log('Request ' + JSON.stringify(request, undefined, 4));
};

page.onResourceReceived = function(response) {

  console.log('Receive ' + JSON.stringify(response, undefined, 4));
};

page.open(Url);

但是,当它只使用 Codeception 或没有 phantomjs 的 PHP 时,我需要解决方案

我发现了一个叫做 MobProxy 的东西: https://github.com/edno/codeception-browsermob

但是我尝试安装它,但我不确定我的步骤是否正确并且它不起作用。

能否请任何人为我提供明确的步骤来从浏览器获取所有标头请求并使用 Codeception 或 PHP 将它们保存到文件中?

【问题讨论】:

    标签: php selenium selenium-webdriver phantomjs codeception


    【解决方案1】:

    你好,有趣的人我找到了这样的解决方案:

    $I = new AcceptanceTester($scenario);
    
    $I->amOnUrl(URL);
    $w=$I->executeJS('return window.performance.getEntries();');
    
    foreach ($w as $itme=>$value)
    {
        echo($value['name']."\n";
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-06-04
      • 2019-01-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-28
      • 2016-03-21
      相关资源
      最近更新 更多