fix element check in waitForDocumentReady method