I am checking PageLoad time of website say moneycontrol, so its taking to much time to load.

Now I want terminate driver.get() if it passes 3 min next step will be driver.close() to close the session.



Appreciate help and suggestions.

  • Can you please elaborate your question ? what mean by terminate driver.get ? what will be the next step ?
    – Gaurav
    Dec 1 '17 at 7:17
  • I mean if driver.get(url) is taking more then 3 min to load the page then driver.close should get instantiated
    – Cloudravi
    Dec 1 '17 at 7:22
  • Which language ? Dec 1 '17 at 13:21

You can set a page load timeout of 3 minutes for your URL:

driver.manage().timeouts().pageLoadTimeout(180, TimeUnit.SECONDS);
  • Does it will work for headless browser ?
    – Cloudravi
    Dec 6 '17 at 9:53
  • Yes it does with html unit driver
    – Swastik
    Dec 6 '17 at 10:20

You can use a explicit wait, it verifies constantly if your webe element is present and if that doesn't occur it pass to the next step

WebDriver driver = new FirefoxDriver(); driver.manage().timeouts().implicitlyWait(180, TimeUnit.SECONDS); driver.get("http://somedomain/url_that_delays_loading"); WebElement myDynamicElement = driver.findElement(By.id("myDynamicElement")); /// action

  • your description is about explicit waits, and then the example you gave is for implicit waits. Feb 2 '18 at 19:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.