Stabilize tests involving absolute timepicker

The asynchronous nature of angular's digest cycle and the page rendering
in the browser can lead to situations in which
`isGlobalLoadingIndicatorHidden()` returns true because the loading
triggered by the previous action has not yet started. In this case
subsequent actions incorrectly assume the loading has already been
completed. This is probably responsible for the flakiness described in #10302.

The newly introduced `waitUntilLoadingHasFinished` first waits for a
duration up to `defaultTimeout` for the loading indicator to appear
before waiting for it to be hidden again. In the best case this will
reduce the false positive rate of `setAbsoluteTimerange()`. In the worst
case the function will wait `defaultTimeout` longer than when just using
`isGlobalLoadingIndicatorHidden`.

fixes #10302
This commit is contained in:
Felix Stürmer 2017-02-13 16:05:50 +01:00
parent 042088085d
commit 345421bd63
No known key found for this signature in database
GPG key ID: F938FEB4935329DA

View file

@ -123,7 +123,7 @@ export default class HeaderPage {
return this.clickGoButton();
})
.then(() => {
return this.isGlobalLoadingIndicatorHidden();
return this.waitUntilLoadingHasFinished();
});
}
@ -144,6 +144,24 @@ export default class HeaderPage {
.click();
}
async waitUntilLoadingHasFinished() {
try {
await this.isGlobalLoadingIndicatorVisible();
} catch (exception) {
if (exception.name === 'NoSuchElement') {
// selenium might just have been too slow to catch it
} else {
throw exception;
}
}
await this.isGlobalLoadingIndicatorHidden();
}
isGlobalLoadingIndicatorVisible() {
return this.remote.setFindTimeout(defaultFindTimeout)
.findByCssSelector('[data-test-subj="globalLoadingIndicator"]:not(.ng-hide)');
}
isGlobalLoadingIndicatorHidden() {
return this.remote.setFindTimeout(defaultFindTimeout * 10)
.findByCssSelector('[data-test-subj="globalLoadingIndicator"].ng-hide');