2

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)

  • Not sure what you want, but I don't think you can change system clock to refresh the cache earlier. Maybe in containers you can do it: https://stackoverflow.com/questions/28973728/change-system-date-time-in-docker-containers-without-impacting-host Another solution would be to change the reponse header to wait less, which I don't think selenium can do. – inf3rno Nov 04 '20 at 10:01

3 Answers3

1

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.

SanzioSan
  • 224
  • 1
  • 2
  • 12
1

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

SarahAs
  • 11
  • 3
0

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);
Gaj Julije
  • 1,538
  • 15
  • 32