-3

Is there a command in the WebDriver API to stop the page load? I have a situation where the page takes forever to load, even though all the stuff I want is there. I just want to simulate manually hitting the X button next to the URL bar in order to stop the page loading.

jononomo
  • 12,340
  • 25
  • 77
  • 134
  • Why do you want to test a page that hasn't fully loaded? – aimbire Sep 26 '17 at 20:33
  • Did you google how to use Selenium to stop the page load? – JeffC Sep 26 '17 at 21:44
  • @aimbire It's a pretty common request actually. On some sites there are some long running scripts that have little to nothing to do with the content on the site so having to wait for them to finish for automation to proceed is a pain and a waste of time. – JeffC Sep 26 '17 at 22:49
  • @JeffC yes, I've spent several hours googling how to solve this problem. `window.stop()` doesn't work for me - not sure why. It seems to stop the page, but it doesn't cause the .get(URL) command from leadfoot (TheIntern) to successfully return. – jononomo Sep 27 '17 at 02:53
  • 2
    See: [How do I do X?](https://meta.stackoverflow.com/questions/253069/whats-the-appropriate-new-current-close-reason-for-how-do-i-do-x) The expectation on SO is that the user asking a question not only does research to answer their own question but also shares that research, code attempts, and results. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer! See also: [ask] – JeffC Sep 27 '17 at 03:20
  • Where is the X button? – DebanjanB Sep 27 '17 at 03:40
  • Please share the URL – iamsankalp89 Sep 27 '17 at 05:11
  • @JeffC do you know the answer to my question? If not, what are you really contributing? – jononomo Sep 27 '17 at 17:44
  • 1
    @jononomo Your question does not meet the standards of SO. I'm contributing by pointing you to links that explain that in more detail. You need to fix your question before it gets downvoted and closed. – JeffC Sep 27 '17 at 18:49
  • @JeffC I guess we disagree -- but go ahead and edit to contribute to my question if you'd like. – jononomo Sep 27 '17 at 19:30
  • Sorry jonomo, but your question not only doesn't belong here, it also goes against the whole idea of testing. If the page takes too long to load, maybe it needs rework. There's a very easy way to do what you want, and even a better way that might not involve manipulating the browser in anyway, but it's so bad that I wouldn't advise at all. – aimbire Sep 27 '17 at 19:54
  • @aimbire respectfully I ask you not to comment if you have nothing to contribute – jononomo Sep 27 '17 at 19:57
  • 1
    I did contribute, you are just being obnoxious now. Feel free to keep doing the wrong way then. – aimbire Sep 27 '17 at 19:59
  • @jononomo It's your job to edit your question and add details to bring it up to SO standards, not mine. If you are unwilling to do that, perhaps you shouldn't ask questions here. – JeffC Sep 27 '17 at 21:20
  • @JeffC This question is not out-of-line. I'm sorry you're bothered by it, but I will continue to use and contribute to the site. – jononomo Sep 27 '17 at 21:53

1 Answers1

0

You could use Javascript executor to stop the window or send keys Keys.ESCAPE.

See :https://sqa.stackexchange.com/questions/5663/is-it-possible-to-stop-page-loading-on-the-browser-using-selenium-web-driver for more details

Shashwat
  • 23
  • 6