简体   繁体   English

Nightwatch JS 中的异步命令执行

[英]Asynchronous command execution in Nightwatch JS

When I run the following code...当我运行以下代码时...

console.log("0001")
browser.pause(5000, function() {
    console.log("0002")
})
console.log("0003")

... the output is 0001, 0003, 0002. How can I get the commands to run sequentially so that the output is 0001, 0002, 0003? ... output 是 0001、0003、0002。我怎样才能让命令按顺序运行,以便 output 是 0001、0002、0003?

Thanks.谢谢。 This worked..这工作..

'Test Commmand Queue': async function (browser) {

    console.log("0001")
    await browser.pause(5000, function() {
        console.log("0002")
    })
    console.log("0003")

}

Output 0001, 0002, 0003 Output 0001, 0002, 0003

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM