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 (将#修改为@)