即使Nightwatch.js中的测试失败,Browserstack也报告成功

编程入门 行业动态 更新时间:2024-10-27 13:21:14
本文介绍了即使Nightwatch.js中的测试失败,Browserstack也报告成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我刚刚开始使用带有浏览器堆栈的守夜器,并且注意到当我们测试失败时,守夜器会记录失败,但浏览器栈不会. 我正在使用的示例测试. 另外,我正在使用BrowserStack的免费试用版.

I just started using nightwatch with browserstack and I'm noticing that when we get a failed test, nightwatch registers the failure, but browserstack does not. sample test I am using. Also I am using free trial version of BrowserStack.

我的问题是:

  • 有什么想法可以告诉浏览器何时测试运行失败?
  • 来自BrowserStack 文档:

    From BrowserStack doc:

    REST API

    REST API

    可以使用 以下代码段:

    It is possible to mark tests as either a pass or a fail, using the following snippet:

    var request = require("request"); request({ uri: "user:key@www.browserstack/automate/sessions/<session-id>.json", method: "PUT", form: { "status": "completed", "reason":"" } });

    两个 状态的潜在值可以是完整的,也可以是错误的. (可选)也可以传递原因.

    The two potential values for status can either be completed or error. Optionally, a reason can also be passed.

    我的问题是:

  • 测试执行后如何获取"session-id"?
  • 如果我已经可以在仪表板上看到已完成"状态怎么办?
  • 推荐答案

  • BrowserStack上的会话只有三种类型的状态: 已完成,错误或超时.如果测试通过或失败,Selenium(以及因此的BrowserStack)将无法理解.通过控制台上出现的测试中的多个断言,可以推断测试是否通过/失败.但是,这些断言不会到达BrowserStack.如您所知,可以使用 REST-API 来更改其状态如果您在控制台中看到失败,则将会话切换为错误".

  • A session on BrowserStack has only three types of statuses: Completed, Error or Timeout. Selenium (and hence, BrowserStack) does not have a way of understanding, if a test has passed or failed. Its by the multiple assertions in your tests that appear on your console, that you infer if a test has passed / failed. These assertions however, do not reach BrowserStack. As you rightly identified, you can use the REST-API, to change the status of the session to 'Error', if you see a failure in your console.

    我建议在执行测试时获取测试的会话ID,因为在测试执行后 之后获取会话ID是一个漫长的过程.在Nightwatch中,您可以按以下方式获取会话ID:

    I would suggest fetching the session ID of the test as the test is being executed, since fetching the session ID after the test execution is a lengthy process. In Nightwatch, you can fetch session ID as follows:

    browser.session(function(session) { console.log(session.sessionId); });

  • 是的,您当然可以在会话完成后更改其状态.这就是REST-API来提供帮助的地方!
  • 更多推荐

    即使Nightwatch.js中的测试失败,Browserstack也报告成功

    本文发布于:2023-06-10 05:45:29,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/608249.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:测试   报告   Nightwatch   js   Browserstack

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!