I have to test an application with Selenium. The application contains external content like ads. In my test I have several times a wait till the document is loaded. This looks like this:
private static final String DOCUMENT_READY_STATE_COMPLETE = "complete";
protected void waitUntilDocumentLoaded() {
wait.until(input -> getDocumentReadyState().equals(DOCUMENT_READY_STATE_COMPLETE));
}
private String getDocumentReadyState() {
return ((JavascriptExecutor) driver).executeScript("return document.readyState").toString();
}
It happens sometimes, that the browser is still loading some resource. As far as I understand I could sometimes accept if the readyState is interactive instead of complete. For example if some ads are not loaded in time, for my test is completely not interesting.
Is it possible somehow to get a list of resources with URLs which have not been loaded yet? Then I could build in an assertion, that checks which resources are mandatory for the test, and which are not.
I use Selenium Java WebDriver 2.53.1 with Firefox 46 under Linux.