Puppeteer has capabilities to wait for network being completely idle, is it possible to achieve the same explicit waiting using python selenium web driver or directly using some javascript work arounds by executing some javascript from the driver context?
waiting for jQuery.active / page ready state etc is common practice, but could it be done that we can query the pending requests and wait until the network is completely idle?
So I see 2 questions in this question:
Note 1: Selenium officially recommends using fluent waits or explicit waits for such issues.
Note 2: I've seen some crude and abstract implementations of waiting for the document ready state as :
public void waitForPagetoLoad() throws InterruptedException {
long millis = 1000;
Thread.sleep(millis);
do {
Thread.sleep(millis);
millis = millis + 2000;
} while (!(((JavascriptExecutor) driver).executeScript("return document.readyState").toString()
.equals("complete")) || millis <= 10000);
Reporter.log("Web page loading is complete in " + (millis / 1000) + " Seconds");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With