简体   繁体   English

使用e2e量角器测试url的http结果

[英]use e2e protractor test http result for url

i need a test to certify the http request results(only json) is right,How do I get it,or use other ways 我需要测试以证明http请求结果(仅json)正确,如何获取或使用其他方法

describe('test', function() {

    it('get a json', function() {
        browser.get('http://.../consumer/2/indexinfo');

    });
});

i don't get it because of the result a json not use element 我没有得到它,因为结果是json不使用element

You can use request to get a json response: 您可以使用request获取json响应:

require("request")({
  url: 'http://.../consumer/2/indexinfo',
  json: true
}, function (error, response, body) {
  if (!error && response.statusCode === 200) {
    console.log(body);
  }
})

Protractor is used for end to end (e2e) testing, with one end being user interaction (like a click), and the other end being DOM changes (like text updating). 量角器用于端到端(e2e)测试,一端是用户交互(如单击),另一端是DOM更改(如文本更新)。 You should be asserting for DOM changes like text updating, not testing the JSON object used to update the DOM. 您应该断言诸如文本更新之类的DOM更改,而不是测试用于更新DOM的JSON对象。

If you must test the response though, it is possible via the NPM module request . 但是,如果必须测试响应,则可以通过NPM模块request

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM