我刚刚开始使用带有浏览器堆栈的守夜器,并且注意到当我们测试失败时,守夜器会记录失败,但浏览器栈不会. 我正在使用的示例测试. 另外,我正在使用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.
我的问题是:
推荐答案
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); });
更多推荐
即使Nightwatch.js中的测试失败,Browserstack也报告成功
发布评论