What is the best way to deal with driver->get(URL) and slow page load?
I basically have a for loop that runs 3 times at most. Within that loop, I have a try/catch block. In the try block, it loads the page with get OR
wait()->until(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::xPath("//body")));
If the get or the wait doesn't work, the page refreshes or the same get command is executed.
Is that truly the best way? I wonder how you guys deal with that? A page that doesn't load properly seems to be one of the main reasons my script regularly doesn't execute fully.
presenceOfElementLocated() for BODY won't ensure if the page have completely loaded.
An ideal solution to slow pageloads would be to set pageLoadTimeout() through a
try-catch{}block as follows:References
You can find a couple of relevant detailed discussions on pageLoadTimeout() in: