0

I want to stop the browser loading process after 20 minutes in selenium webdriver script.

Please suggest, how to do this?

7
  • I am assuming that when you say 'Page' content you mean the ajax elements on a web page and when you say 'Browser' content you mean the rest of the elements, am I correct?
    – Yash
    Commented May 8, 2014 at 7:36
  • 'Page' refers to some web page like 'index.php' and browser refers to web browser like 'Firefox'. And I need help when 'index.php' is loaded (browser screen is blank with whitespace) and browser's loading process is still in progress. Commented May 8, 2014 at 11:58
  • Not obvious what you want to accomplish. "some page loading problem while executing my script" is SO vague I was tempted to downvote. Do you want to execute some code during page load? Does your code fails because some elements are not present/visible? What is the error message? What is expected behavior? Consider reading up on WebDriverWait and ExpectedCondition. Many good answers for page load problems on Stack Overflow. Also, there is no THE UNIVERSAL METHOD - for modern web some pages, Javascript will NEVER stop updating SOME parts of the page. Commented May 8, 2014 at 23:07
  • change the question to exact requirement Commented May 9, 2014 at 7:39
  • You have a web server configured with more than 20 minutes for timeout? That's awfully generous. Why would you need something like that?
    – MichaelF
    Commented May 9, 2014 at 12:57

1 Answer 1

1

How to do it? Set some form of timer with an expiration of 20 minutes (either a selenium wait for one of the objects on the page if you want to be able to continue if it does load, or a thread.sleep if you literally want to sleep exactly 20 minutes and then quit). At the expiration of the timer, if it was a selenium wait, put your driver.close in the cleanup method; if it was a thread.sleep, call driver.close directly after.

But why? If your page isn't loading or is hanging, 20 minutes is a ridiculously long timeout. Will your customers wait 20 minutes on the page? Or will they give up after 30 seconds or so? And furthermore, why is your page hanging for over 20 minutes in the first place? What test case requires staring at a blank screen for 20 minutes then closing the browser? Are you sure it's an appropriate test case in the first place? If the test is "The page loads successfully", I suggest that 20 minutes is far, far too long.

1
  • Thanks for appreciative help!! Actually that problem was because of ci tool. I have resolved the problem. Commented May 14, 2014 at 5:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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