How to make E2E stable without using browser.pause?

Viewed 176

I want to write an E2E test for a service using selenium webdriverio. and caching in backend is causing trouble.

There's a request in backend that cache data for a certain amount of time. this leads into the test being false negative cause it's running faster than that certain cache time. Currently I am using browser.pause()

How can i make this test more stable without await browser.pause(XXXX)

3 Answers

Does your page have any loading indicators?

If so instead of waiting around for a static amount of time, you could wait for the loading indicator to not be visible before you do your expects like this:

let EC = protractor.ExpectedConditions;
browser.wait(EC.not(EC.visibilityOf($(element_locator))));

Most likely the loading indicator goes away after a request is finished. It should be more reliable to do expects after that.

Visit link : https://medium.com/@sdet.ro/how-to-use-smart-waits-with-protractor-how-to-use-expected-conditions-with-protractor-10c545c670be

l

et EC = protractor.ExpectedConditions;
let testSearchingLookingMethod = function(elementFinder) {
let searchesForText = function() {
return elementFinder.getText().then(function(actualTextResultedFromAPromise) {
return actualTextResultedFromAPromise;
});
};
return EC.and(EC.presenceOf(elementFinder), searchesForText);
};
//How to run the above function:
browser.wait(testSearchingLookingMethod(element(by.css(‘.divName’)), 5000);
Related