• <bdo id='77Jn7'></bdo><ul id='77Jn7'></ul>
  • <i id='77Jn7'><tr id='77Jn7'><dt id='77Jn7'><q id='77Jn7'><span id='77Jn7'><b id='77Jn7'><form id='77Jn7'><ins id='77Jn7'></ins><ul id='77Jn7'></ul><sub id='77Jn7'></sub></form><legend id='77Jn7'></legend><bdo id='77Jn7'><pre id='77Jn7'><center id='77Jn7'></center></pre></bdo></b><th id='77Jn7'></th></span></q></dt></tr></i><div id='77Jn7'><tfoot id='77Jn7'></tfoot><dl id='77Jn7'><fieldset id='77Jn7'></fieldset></dl></div>

    <legend id='77Jn7'><style id='77Jn7'><dir id='77Jn7'><q id='77Jn7'></q></dir></style></legend>

      1. <small id='77Jn7'></small><noframes id='77Jn7'>

      2. <tfoot id='77Jn7'></tfoot>
      3. 使用量角器从 chromedriver 获取 HTTP 请求(性能日志

        时间:2023-09-03
          <tbody id='gbe4O'></tbody>

      4. <i id='gbe4O'><tr id='gbe4O'><dt id='gbe4O'><q id='gbe4O'><span id='gbe4O'><b id='gbe4O'><form id='gbe4O'><ins id='gbe4O'></ins><ul id='gbe4O'></ul><sub id='gbe4O'></sub></form><legend id='gbe4O'></legend><bdo id='gbe4O'><pre id='gbe4O'><center id='gbe4O'></center></pre></bdo></b><th id='gbe4O'></th></span></q></dt></tr></i><div id='gbe4O'><tfoot id='gbe4O'></tfoot><dl id='gbe4O'><fieldset id='gbe4O'></fieldset></dl></div>

          <bdo id='gbe4O'></bdo><ul id='gbe4O'></ul>
          <legend id='gbe4O'><style id='gbe4O'><dir id='gbe4O'><q id='gbe4O'></q></dir></style></legend>
        • <small id='gbe4O'></small><noframes id='gbe4O'>

          <tfoot id='gbe4O'></tfoot>

                1. 本文介绍了使用量角器从 chromedriver 获取 HTTP 请求(性能日志)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在使用量角器进行带角度的 e2e 测试,并且我正在拼命地尝试获取带有标头和正文的 HTTP 请求日志.我已经像这样配置量角器:

                  I'm using protractor for my e2e tests with angular and I'm trying desperately to get HTTP requests logs with headers and body. I've configured protractor like this:

                    {
                  
                      useAllAngular2AppRoots: true,
                      ignoreUncaughtExceptions: true,
                  
                      maxSessions: 1,
                      multiCapabilities: [
                          {
                              'name': 'desktop',
                              'browserName': 'chrome',
                              loggingPrefs: {"driver": "ALL", "browser": "ALL", 'performance': 'ALL'},
                              chromeOptions: {
                                  binary: process.env.CHROME_BIN,
                                  args: ["--headless", "--disable-gpu", "--no-sandbox"],
                                  perfLoggingPrefs: {
                                      'traceCategories': 'blink.console,disabled-by-default-devtools.timeline'
                                  }
                              }
                          }
                      ],
                  
                      framework: "custom",
                      frameworkPath: require.resolve("protractor-cucumber-framework"),
                  
                      //...
                  };
                  

                  在每个场景之后,我都在执行这个钩子:

                  After each scenario, I'm executing this hook:

                  browser.manage().logs().get("browser").then(logs => 
                    //...
                  )
                  

                  但我得到的只是控制台日志,但没有 http 请求.有没有办法从量角器中的 chromedriver 获取这些?

                  But all I get are console logs but no http requests. Is there any way to get those from chromedriver within protractor?

                  这里是 chromedriver 文档的链接,其中提到了性能日志:https://sites.google.com/a/chromium.org/chromedriver/logging/performance-log

                  Here is a link to chromedriver doc mentioning performance logs: https://sites.google.com/a/chromium.org/chromedriver/logging/performance-log

                  推荐答案

                  您需要添加以下 chromeOptions 包括 perfLoggingPrefsloggingPrefs如 https://github.com/angular/protractor-cookbook/blob/master/protractor-javascript/example-network/conf.js

                  You will need to add the following chromeOptions including perfLoggingPrefs and loggingPrefs as shown in https://github.com/angular/protractor-cookbook/blob/master/protractor-javascript/example-network/conf.js

                  capabilities: {
                      'browserName': 'chrome',
                      'chromeOptions': {
                        'perfLoggingPrefs': {
                          'enableNetwork': true,
                          'enablePage': false,
                          'enableTimeline': false
                        }
                      },
                      loggingPrefs: {
                        performance: 'ALL',
                        browser: 'ALL'
                      }
                    },
                  

                  在获取日志时,我编写的示例在 afterEach 方法中记录日志,以便在每次测试后输出.

                  When getting the logs, the example I wrote has the logging in an afterEach method to output after each test.

                    afterEach(() => {
                      browser.manage().logs().get('performance').then((browserLogs) => {
                        browserLogs.forEach((browserLog) => {
                          var message = JSON.parse(browserLog.message).message;
                          if (message.method == 'Network.responseReceived') {
                            console.log(message);
                          }
                        });
                      });
                    });
                  

                  从日志中您应该能够看到加载 javascript 文件、资产等时发出的任何获取请求.

                  From the logs you should be able to see any get requests made when loading javascript files, assets, etc.

                  根据评论更新答案.如果你使用 'Network.requestWillBeSent',你可以查看 POST.

                  Updating answer per comment. If you use 'Network.requestWillBeSent', you can view POSTs.

                  这篇关于使用量角器从 chromedriver 获取 HTTP 请求(性能日志)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Selenium - 元素不可点击 下一篇:在运行测试时放宽 Chrome 的 CSP (webdriver) (Content-

                  相关文章

                  最新文章

                  1. <tfoot id='Suo8K'></tfoot>

                    <legend id='Suo8K'><style id='Suo8K'><dir id='Suo8K'><q id='Suo8K'></q></dir></style></legend>

                    <small id='Suo8K'></small><noframes id='Suo8K'>

                      • <bdo id='Suo8K'></bdo><ul id='Suo8K'></ul>
                    1. <i id='Suo8K'><tr id='Suo8K'><dt id='Suo8K'><q id='Suo8K'><span id='Suo8K'><b id='Suo8K'><form id='Suo8K'><ins id='Suo8K'></ins><ul id='Suo8K'></ul><sub id='Suo8K'></sub></form><legend id='Suo8K'></legend><bdo id='Suo8K'><pre id='Suo8K'><center id='Suo8K'></center></pre></bdo></b><th id='Suo8K'></th></span></q></dt></tr></i><div id='Suo8K'><tfoot id='Suo8K'></tfoot><dl id='Suo8K'><fieldset id='Suo8K'></fieldset></dl></div>