xyz*_*xyz 2 selenium jasmine protractor
我正在使用ProtractorwithJasmine为Angular2应用程序编写 e2e 测试用例。
我有两个问题:
1. 关于 DefaultTimeoutInterval
我有一个了解,倒计时开始,每当一个承诺开始,如果承诺没有得到指定的范围内完成defaultTimeoutInterval的protractor.conf.js,量角器将导致控制台上的错误。但是如果承诺在 内完成,defaultTimeoutInterval那么倒计时将被重置,并会在下一个承诺开始时开始。
如果上述情况属实,我想澄清一下,如果我有一系列承诺,那么倒计时何时重置?在链中的所有promise完成之后还是在每个promise完成之后?
如果在链中的所有承诺完成后倒计时重置,那么正确的做法是将承诺作为it()/fit() blocks?
我在下面有一个示例代码来解释更多我想问的问题。
it("when does protractor's default timeout interval gets reset?", () => {
expect("a single promise here").toBe('something'); // I believe, after the promise inside the expect block finishes, the defaultTimeoutInterval should Reset.
// what happens if I have a chain of promises, like below?
// whether the defaultTimeoutInterval resets after every single promise inside the method `validateSuccessAlert()` and then the chained promises are finsihed?
// or will it reset on completion of every single promise?
PO.validateSuccessAlert('a method which has chained promises inside itself, returns a promise').then(() => {
browser.waitForAngularEnabled(false).then(() => {
PO.getEmailActivationLink('xxxxxx').then((activationCode) => {
PO.openNewTab(activationCode).then(() => {
PO.switchToTab(1).then(() => {
expect(PO.isVisible(element(by.css('.activateMailBox h3 small')))).toBeTruthy();
expect(element(by.css('.activateMailBox h3 small')).getText()).toBe('Congratulations!!');
expect(PO.isNotVisible(PO.getButtonByText('Proceed')));
PO.switchToTab(0);
browser.waitForAngularEnabled(true); // Re-enable the angular wait
})
})
});
});
})
Run Code Online (Sandbox Code Playgroud)
})
2.关于allScriptsTimeout
我真的不明白这一点,这很重要:每个文件中有一个规范?如果您也可以对此进行一些解释,那就太好了。
1) defaultTimeoutInterval 是 jasmine 的超时时间,每个超时it都不会使测试永远或很长时间运行 - http://www.protractortest.org/#/timeouts#timeouts-from-jasmine
将其设置为您认为it不应超过的某个默认值。使用以下语法覆盖您的测试是否会比默认超时时间少得多或多得多:
describe('Some feature', function () {
it('can be really slow', function () {
}, 5 * 60 * 1000) // 5 minutes
it('can be really fast', function () {
}, 5000) //5 seconds
})
Run Code Online (Sandbox Code Playgroud)
2) allScriptsTimeout 是量角器中每个异步命令的超时时间,不要执行太长时间。
http://www.protractortest.org/#/timeouts#timeouts-from-webdriver
我通常不会将它设置超过 10 秒,以免让每个命令(如 .sendKeys()、.click() 等)花费太多时间。有时在网格中运行时需要增加,或者执行一些像巨大的 .executeScript() 之类的长命令。
| 归档时间: |
|
| 查看次数: |
3778 次 |
| 最近记录: |