Loud QA
Loud QA

Reputation: 23

How to make E2E stable without using browser.pause?

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)

Upvotes: 2

Views: 395

Answers (3)

SarahAs
SarahAs

Reputation: 36

With WebdriverIO you can use waitForDisplayed to wait until an element is loaded on the page(https://webdriver.io/docs/api/element/waitForDisplayed.html)

$(selector).waitForDisplayed({ timeout, reverse, timeoutMsg, interval })

Upvotes: 2

SanzioSan
SanzioSan

Reputation: 254

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.

Upvotes: 1

Gaj Julije
Gaj Julije

Reputation: 2183

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);

Upvotes: 0

Related Questions