如何解决Nightwatchjs 测试在 `before` 钩子完成之前运行
我使用此代码设置了 nightwatchjs 项目。
# Enable module mode for anotherpkg.
cd $GOPATH/src/github.com/anotherproject/anotherpkg
go mod init github.com/anotherproject/anotherpkg
# Use the local copy of github.com/myproject/mypkg instead of the latest GitHub snapshot.
go mod edit -replace github.com/myproject/mypkg=$GOPATH/src/github.com/myproject/mypkg
go get -d github.com/myproject/mypkg
# Resolve any additional missing dependencies to their latest versions.
go mod tidy
module.exports = {
beforeEach: browser => {
// Starts a new session for each test
browser.refresh();
},before: async browser => {
// Get the encrypted token
const { token } = await authorizeUser({ browser });
// Create the Test Tool instance
await initializeTestTool({
browser,channelOriginId: CHANNEL_ORIGIN_ID,token,});
},...allTests.reduce((acc,test) => ({ ...acc,...require(test) }),{})
};
部分正在向对象添加更多测试。这是运行的第一个测试。
...allTests.reduce
我正在使用此脚本来启动测试 module.exports = {
'Verify Level 1 Taxonomies are Showing': browser => {
// Specify the selector mode before using any selectors since the prevIoUs test Could have changed the mode
browser.useCss();
// Wait for the frame to load
browser.waitForElementVisible('iframe',RESPONSE_WAIT_TIME * 3);
// Switch context to the iframe
browser.frame(0);
// Change selector mode to XPath. XPath allows selectors with text matching logic
browser.useXpath();
const qr0 = "//span[contains(text(),'Something else')]";
// Wait for the quick reply to be shown
browser.waitForElementVisible(qr0,RESPONSE_WAIT_TIME);
// Click the quick reply
browser.click(qr0);
const taxonomyResponse = `//div[contains(text(),'${l1TaxonomyResponse}')]`;
// Make sure the chat bot gives the expected response
browser.waitForElementVisible(taxonomyResponse,RESPONSE_WAIT_TIME);
// Make sure all the level 1 taxonomy quick replies are displayed
for (const quickReply of l1QuickReplies) {
const quickReplyText = `//span[contains(text(),'${quickReply}')]`
browser.waitForElementVisible(quickReplyText,RESPONSE_WAIT_TIME);
}
},};
我遇到的问题是第一个测试在 nightwatch automation.test.js -e chrome
钩子完成之前开始运行。如果完成时间太长,则在等待显示元素时第一个测试将失败。
before
如何强制 nightwatchjs 在运行自动化测试之前等待 browser.waitForElementVisible('iframe',RESPONSE_WAIT_TIME * 3);
钩子完成?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。