Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to wait for page load to complete in Chrome browser

What is the command in webdriver to wait for page to load fully before performing action on the page in CHROME browser?

PageLoadTimeOut is not waiting for the page load to complete in Chrome whereas it is working fine in firefox.

In Chrome, if webelement is there on the page, webdriver is performing the action on webelement while page is getting loaded. This is causing scripts to fail randomly with exception 'element is not clickable'.

Please let me know if there is any solution for this.

Thanks

like image 616
user3882097 Avatar asked Nov 11 '22 04:11

user3882097


1 Answers

You can use custom wait methods for an element to be enable or visible on the page.

For Example create a custom method isElementEnable using following code:

driver.findElement(locator).isEnabled();

Or use the following code to check if the element is visible on page:

driver.findElement(locator).isDisplayed();

pass your element locator as input parameter to the method.

Or Alternatively use implicit wait:

driver.manage().timeouts().implicitlyWait(number_of_seconds, TimeUnit.SECONDS);

Hope this will help.

like image 118
AGill Avatar answered Dec 05 '22 19:12

AGill