How to continue the intern test once timeout for leadfoot/Session#executeAsync calls has reached

笑着哭i 提交于 2019-12-25 14:28:27

问题


There are array of URLs to load within an application. A page ready event is fired once the page load. However, when running on sauce labs, the event does not fire on a random page and test fails.

Is there any way to continue the tests if the event does not fire?

              return remote.get(url)
                          .setExecuteAsyncTimeout(20000)
                          .then(function() {
                                var pageLoadEvent = conf.get("pageLoadEvent");
                                console.log("waiting for " + pageLoadEvent + " event to occur");
                                remote.executeAsync(function(done) {
                                    window.addEventListener(pageLoadEvent, function() {
                                        done();
                                    }, false);
                                }, []);
                            })

回答1:


You can use a catch callback after the executeAsync to consume the error, although if the ready event can be skipped, is it actually necessary to the test?

You should also return the result of any Command chains created within a then callback to ensure the asynchronous chain continues properly. Otherwise, the outer Command chain will continue without waiting for the executeAsync to complete.

return remote.executeAsync(function (done) {
    ...
}).catch(function (error) {
    // Do nothing here to consume the error, or rethrow it to have the test fail.
})


来源:https://stackoverflow.com/questions/31752452/how-to-continue-the-intern-test-once-timeout-for-leadfoot-sessionexecuteasync-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!