【问题标题】:Restler with CucumberRestler 用黄瓜
【发布时间】:2020-06-16 17:37:21
【问题描述】:

我对量角器/黄瓜和休息者完全陌生。我正在使用打字稿。下面是我用来访问端点 url 并获取响应的代码

Given('Hit the {string}', async (string) => {
  browser.quit()
  var data: any = get(string.replace(/\s+/g, ''));
  console.log("In method:" + string.replace(/\s+/g, ''));
  console.log(data.response);
});

这将打印以下内容:

在方法中:端点 URL

未定义

我希望打印响应和响应代码。

【问题讨论】:

  • 我不熟悉 restler 包,但它可能是一个异步问题。试试这个console.log(await data.response);

标签: typescript protractor cucumber restler


【解决方案1】:

感谢您的回复。下面的代码有效

Given('Hit the {string}', async (endpointUrl) => {
    await get(endpointUrl).on('complete', async (result, response) => {
        console.log(response.statusCode);
    });
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-21
    • 2021-04-17
    • 2017-11-13
    • 2019-12-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多