量角器browser.manage()。logs()。get('performance')未检索服务器响应主体

时间:2018-10-11 06:17:59

标签: selenium protractor selenium-chromedriver

Selenium服务器独立v 3.0.1 Chromedriver v2.42 Chrome:最新

我的afterEach函数中包含以下代码,该代码按预期失败。但是,当Jasmine期望失败并且我输出浏览器日志时,在日志对象中的任何地方都看不到响应正文吗?我在那里看到了所有标头数据,但没有响应正文。

这是我从另一个答案中提取的代码(我丢失了链接)。效果很好。

browser.manage().logs().get('performance').then(async function(browserLogs) {
            browserLogs.forEach(async function(browserLog) {
                var message = JSON.parse(browserLog.message).message;
                if (message.method == 'Network.responseReceived') {
                    await expect(errorCodes)
                        .not.toContain(message.params.response.status,
                            'A status code of ' + message.params.response.status + ' was returned for the following request:\n\n' + JSON.stringify(message, null, 2));
                };
            });
        });

因此,当我运行测试并发现500错误时,期望行会失败并转储浏览器日志对象,但没有响应正文或结果部分,因此我无法获得有关失败原因的详细信息。有任何想法吗?以下是测试失败时得到的示例输出。请注意,没有响应正文数据。

{
  "method": "Network.responseReceived",
  "params": {
    "response": {
      "connectionId": 1067,
      "connectionReused": false,
      "encodedDataLength": 1233,
      "fromDiskCache": false,
      "fromServiceWorker": false,
      "headers": {
        "Connection": "close",
        "Content-Length": "63",
        "Content-Type": "application/json; charset=utf-8",
        "Date": "Thu, 11 Oct 2018 05:32:39 GMT",
        "Server": "nginx",
        "Vary": "Accept-Encoding"
      },
      "headersText": "",
      "mimeType": "application/json",
      "protocol": "http/1.1",
      "remoteIPAddress": "",
      "remotePort": 443,
      "requestHeaders": {
        "Accept": "application/json",
        "Accept-Encoding": "gzip, deflate, br",
        "Accept-Language": "en-US,en;q=0.9",
        "Authorization": "",
        "Connection": "keep-alive",
        "Content-Length": "162",
        "Content-Type": "application/json",
        "Cookie": "",
        "Host": "test.com",
        "Origin": "https://test.com",
        "Referer": "https://test.com",
        "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"
      },
      "requestHeadersText": "",
      "securityDetails": {
        "certificateId": 0,
        "certificateTransparencyCompliance": "compliant",
        "cipher": "",
        "issuer": "",
        "keyExchange": "",
        "keyExchangeGroup": "",
        "protocol": "TLS 1.2",
        "sanList": [
          "test.com"
        ],
        "signedCertificateTimestampList": [
          {
            "hashAlgorithm": "SHA-256",
            "logDescription": "Google 'Pilot' log",
            "logId": "",
            "origin": "Embedded in certificate",
            "signatureAlgorithm": "",
            "signatureData": "",
            "status": "Verified",
            "timestamp": 
          },
          {
            "hashAlgorithm": "SHA-256",
            "logDescription": "DigiCert Log Server 2",
            "logId": "",
            "origin": "Embedded in certificate",
            "signatureAlgorithm": "ECDSA",
            "signatureData": "",
            "status": "Verified",
            "timestamp": 1533185101362
          }
        ],
        "subjectName": "test.com",
        "validFrom": ,
        "validTo": 
      },
      "securityState": "secure",
      "status": 500,
      "statusText": "Internal Server Error",
      "timing": {
        "connectEnd": 338.032,
        "connectStart": 0.318,
        "dnsEnd": 0.318,
        "dnsStart": 0.314,
        "proxyEnd": -1,
        "proxyStart": -1,
        "pushEnd": 0,
        "pushStart": 0,
        "receiveHeadersEnd": 1368.312,
        "requestTime": 520601.243295,
        "sendEnd": 338.288,
        "sendStart": 338.169,
        "sslEnd": 338.022,
        "sslStart": 168.702,
        "workerReady": -1,
        "workerStart": -1
      },
      "url": "https://test.com/api/postSomething"
    },
    "timestamp": ,
    "type": "XHR"
  }
}'.

0 个答案:

没有答案