Home > database >  Selenium opens a blank page, how to retry
Selenium opens a blank page, how to retry

Time:11-05

I am writing selenium framework with multiple environment support, and lower envs are slower and sometimes fail to load a page - completely blank page is loaded after 30s. How can I add a global retry mechanism to try again in such scenario, other than modyfing every method that opens new page.

What such mechanism should do, refresh the page and continue? I have no good ideas.

CodePudding user response:

You can build on dynamic function which includes pageload strategy and check if the document ready state is complete or not if these two conditions aren't met then u can reiterate the initialization process.

void waitForLoad(WebDriver driver) { new WebDriverWait(driver, 30).until((ExpectedCondition) wd -> ((JavascriptExecutor) wd).executeScript("return document.readyState").equals("complete")); }

  • Related