相关疑难解决方法(0)

什么时候我们应该使用.then和Protractor Promise?

我和Protractor有很多不稳定因素,我确信有些东西我不明白.有时我需要在继续之前单击按钮时使用.then(),有时它没有任何影响,我不应该使用.then()或测试失败.

我想知道在Protractor中测试时我应该何时使用.then()回调?示例:

createAccountForm = $('#form-create-account');
submitButton = createAccountForm.$('button[type=submit]');

browser.wait(EC.elementToBeClickable(submitButton), 5000);
submitButton.click(); // .then(function(){   <-- uncomment in the .then form

// find the confirmation message
var message = $('.alert-success');
browser.wait(EC.visibilityOf(message), 5000);
log.debug('After visibilityOf');

expect(message.isPresent()).to.be.eventually.true;
// }); --> uncomment when in .then form
Run Code Online (Sandbox Code Playgroud)

当我使用这种形式的测试(没有.then())时,我在浏览器上看到点击按钮没有完成,测试继续以下期望然后停止.

如果我使用.then()表单,则单击按钮即可完成,测试将继续,不会出现错误.

在其他测试中,单击按钮时我不需要使用then()回调.

那么,我什么时候应该使用.then(),什么时候不使用?

让 - 马克

promise protractor

35
推荐指数
1
解决办法
3万
查看次数

标签 统计

promise ×1

protractor ×1