简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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