0

在应用程序中加载了一系列 URL。页面加载后会触发页面就绪事件。但是,在酱实验室上运行时,该事件不会在随机页面上触发并且测试失败。

如果事件没有触发,有什么方法可以继续测试?

              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);
                                }, []);
                            })
4

1 回答 1

0

你可以catch在 之后使用回调executeAsync来消费错误,虽然如果可以跳过 ready 事件,那么测试是否真的有必要?

您还应该返回在then回调中创建的任何命令链的结果,以确保异步链正常继续。否则,外部命令链将继续,无需等待executeAsync完成。

return remote.executeAsync(function (done) {
    ...
}).catch(function (error) {
    // Do nothing here to consume the error, or rethrow it to have the test fail.
})
于 2015-07-31T20:35:51.043 回答