1

When using the WebDriver driver for Chrome a chrome window opens, and navigates to the specified page.

Is there a way to stop the window from opening?

Edit: I am using it to scrape the web page so there is no need for me to see the actual webpage. The desired behaviour would be that the scraping would be done "Silently"?

J4C3N-14
  • 686
  • 1
  • 13
  • 32

1 Answers1

2

What you are talking about is called a headless browser.

You have several options to choose from:

  • fake a display and let selenium and a browser think you have a real one. See xvfb.
  • use PhantomJS browser
  • run your tests against BrowserStack or SauceLabs selenium servers (or have your own one)

See also:

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • Hi, Thanks for the answer, one question could I just substitute Chrome for PhantomJs? Drivers and all? – J4C3N-14 Nov 18 '14 at 00:13
  • @J4C3N-14 by default it would be with a head; but if used with `xvfb` you can "fake" a headless mode. – alecxe Nov 18 '14 at 00:15
  • Hi, thanks for your help. I'm now "Headless" along with your answer pointing me down the right path and this questions answers: http://stackoverflow.com/questions/14122185/how-to-run-ghostdriver-from-java it all ended up being quite painless. Although I had no need to use xvfb to run it headless? – J4C3N-14 Nov 18 '14 at 20:13
  • Also the speed of the scraping has been increased quite dramatically by being headless, side effect of not having to load all the graphics? – J4C3N-14 Nov 18 '14 at 20:15