Javascript 将night watch从1.3.2升级到1.3.4打破了现有的测试,特别是在page对象中

Javascript 将night watch从1.3.2升级到1.3.4打破了现有的测试,特别是在page对象中,javascript,node.js,async-await,nightwatch.js,nightwatch,Javascript,Node.js,Async Await,Nightwatch.js,Nightwatch,我使用的是夜视1.3.2版。所有的测试都进行得很好,直到我将夜班升级到最新版本1.3.4。测试在页面对象中特别中断。我已经查看了night watch 1.3.4的发行说明,它有一个新功能,支持页面对象async/await-https://github.com/nightwatchjs/nightwatch/releases. 我相信我收到的错误消息是指出用async await包装页面对象。我想知道如何使用async/await更新现有页面对象。带有async await的例如-page对象

我使用的是夜视1.3.2版。所有的测试都进行得很好,直到我将夜班升级到最新版本1.3.4。测试在页面对象中特别中断。我已经查看了night watch 1.3.4的发行说明,它有一个新功能,支持页面对象
async/await-https://github.com/nightwatchjs/nightwatch/releases.

我相信我收到的错误消息是指出用async await包装页面对象。我想知道如何使用async/await更新现有页面对象。带有async await的例如-page对象将非常有助于参考。我在下面列出了我的带有页面对象和错误消息的示例测试,它在将night watch更新到其最新版本之前运行良好。任何想法或帮助都将不胜感激

Test
 it('Verify Login', async (browser)=> {
     await this.loginTest.loginSuccess(browser.globals.Username,browser.globals.Password);
     this.homepage.expect.element('@profile').to.be.visible;
  });
问题解决了我用异步等待包装函数的问题

 async loginSuccess(username,pwd){
            await this.navigate()
            await this.waitForBody()
            await this.click('@btnSignInRegister')
            //await this.pause(7000);
            await this.waitForElementVisible('@btnSelectBusiness',5000)
            await this.click('@btnSelectBusiness')
            await this.waitForElementVisible('@txtUsernameInput',5000)
            await this.setValue('@txtUsernameInput',username)
            await this.setValue('@txtPasswordInput',pwd)
            await this.click('@signInBtn')
            await this.waitForBody()
        },
        async logoutSuccess(){
           await this.waitForElementVisible('@btnProfile',5000)
           await this.click('@btnProfile')
           await this.waitForElementVisible('@btnLogout',5000)
           await this.click('@btnLogout')
        },

我能够解决这个问题。通过使用wait将页面对象命令函数升级为异步函数,我解决了这个问题。请在主要帖子中找到这个例子

来自此相关GitHub问题:


我可以知道你看到的错误是什么吗?
 async loginSuccess(username,pwd){
            await this.navigate()
            await this.waitForBody()
            await this.click('@btnSignInRegister')
            //await this.pause(7000);
            await this.waitForElementVisible('@btnSelectBusiness',5000)
            await this.click('@btnSelectBusiness')
            await this.waitForElementVisible('@txtUsernameInput',5000)
            await this.setValue('@txtUsernameInput',username)
            await this.setValue('@txtPasswordInput',pwd)
            await this.click('@signInBtn')
            await this.waitForBody()
        },
        async logoutSuccess(){
           await this.waitForElementVisible('@btnProfile',5000)
           await this.click('@btnProfile')
           await this.waitForElementVisible('@btnLogout',5000)
           await this.click('@btnLogout')
        },
If async/await is being used, chaining is not possible anymore, 
because the commands will return a Promise. 
But in your testcase, there's no need to use await, 
since you're not using the result of the command.