当在本地运行测试时,它成功了,但是当配置远程网格时,它失败了
1) Scenario: Login - features/api.feature:10
Step: When he enters his credentials - features/api.feature:13
Step Definition: node_modules/serenity-js/src/serenity-cucumber/webdriver_synchroniser.ts:46
Message:
function timed out after 5000 milliseconds如何增加超时值?
谢谢& Ciao Stefan
发布于 2017-01-28 09:28:28
嗨,Stefan,感谢你尝试一下Serenity/JS!
这里有几个选项,这取决于什么是超时。
由于是Protractor负责超时,因此您需要查看protractor.conf.js文件。
让我们假设您的protractor.conf.js文件看起来或多或少像下面的代码片段。为了简洁起见,我省略了serenity-js.org中描述的Serenity/JS和Cucumber.js配置
exports.config = {
baseUrl: 'http://your.webapp.com',
// Serenity/JS config
framework: ...
specs: [ 'features/**/*.feature' ],
cucumberOpts: {
// ...
},
};0。增加总体超时
首先,您可能希望增加所有测试的总体超时时间(对于Protractor 5.0.0,默认值设置为11s)。
为此,将allScriptsTimeout条目添加到您的配置中:
exports.config = {
allScriptsTimeout: <appropriate_timeout_in_millis>
// ... rest of the config file
}1.加载页面
如果测试中的webapp加载速度很慢,您可以调整getPageTimeout属性(默认设置为10s):
exports.config = {
getPageTimeout: <appropriate_timeout_in_millis>
// ... rest of the config file
}黄瓜2.特定的黄瓜步骤
如果特定的黄瓜步骤超时(这很可能是这里的情况,因为Cucumber.js将default value of the cucumber step timeout设置为5s),您可以通过更改步骤定义(以毫秒为单位的值)来增加超时:
this.Given(/^When he enters his credentials$/, { timeout: 10 * 1000 }, () => {
return stage.theActorInTheSpotlight().attemptsTo(
Login.withTheirCredentials()
);
});请注意,在上面的答案中,我假设您正在使用Serenity/JS和Cucumber来测试一个Angular应用程序。如果你使用不同的web框架(如React),当Protractor等待Angular加载时,测试可能也会超时。
如果这描述了您的场景,那么您可能需要使用ignoreSynchronization
exports.config = {
onPrepare: function() {
browser.ignoreSynchronization = false;
}
// ... rest of the config file
}要了解更多信息,请查看Protractor documentation和前面提到的Cucumber docs。我还将很快在serenity-js.org上添加一篇文章来描述不同的选项,以便所有内容都集中在一个地方:-)
希望这能有所帮助!
1月
https://stackoverflow.com/questions/41806327
复制相似问题