How to wait for page load in selenium webdriver

How to wait for page load in selenium webdriver



I am using selenium-server-3.7.1 and Firefox 57



How to wait for page to load completely



I tried following
return ((JavascriptExecutor) driver).executeScript(
"return document.readyState").equals("complete");



but it is not working



Basically the above command is not recognizing below operations
[testng] 1535139249496 addons.productaddons INFO sending request to: https://aus5.mozilla.org/update/3/GMP/57.0.4/20180103231032/Linux_x86_64-gcc3/en-US/release/Linux%204.1.12-112.14.10.el7uek.x86_64%20(GTK%203.22.10%2Clibpulse%2010.0.0)/default/default/update.xml
[testng] 1535139249669 addons.productaddons INFO Completed downloading document
[testng] 1535139249818 addons.productaddons INFO downloadXHR File download. status=200
[testng] 1535139249821 addons.productaddons INFO Downloaded file will be saved to /tmp/tmpaddon-c61a84
[testng] 1535139738375 addons.manager INFO Skipping background update check
[testng] 1535139978387 DeferredSave.extensions.json DEBUG Save changes
[testng] 1535139978387 DeferredSave.extensions.json DEBUG Starting timer
[testng] 1535139978409 DeferredSave.extensions.json DEBUG Starting write
[testng] 1535139978412 DeferredSave.extensions.json DEBUG Write succeeded



I gave hard sleep of 30 seconds to finish these operations
Is there a way to wait for these operations to be completed?




2 Answers
2



In Automation script, There needs to wait on multiple instance. There can not be use Thread.Sleep(); every time. Page need to wait for JQuery, JavaScript, Angular loading. And which can not be handle by only document.readyState We have to wait for all substances if application is built on. So, We can create single method to wait for Page load and that method can call multiple times.


document.readyState



This is the Blog link for same, Which will help you to understand it. Click Here



You can include those method, on which your application is build.



If in case Blog link might loss, there is sample Github project is available for same. Click Here


Wait wait = new FluentWait(driver)
.withTimeout(30000, TimeUnit.SECONDS) .pollingEvery(5, TimeUnit.SECONDS) .ignoring(NoSuchElementException.class);



Hope this will help you





Please describe it so that questioner understand it
– iamsankalp89
Sep 12 at 12:38






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)