1

I am using Selenium and trying to initialize the Chrome driver to start without a start up window.

ChromeOptions options= new ChromeOptions();
options.addArguments("--no-startup-window");
//I tried this line also: options.addArguments("--silent-launch");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(Capabilities);

I am getting the following exception:

Unknown error: Chrome failed to start: exited normally

Can anybody help me?

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
user5414372
  • 11
  • 1
  • 2

3 Answers3

4

You need to download the binary first from selenium website, download binary according to your specifications:-

http://chromedriver.storage.googleapis.com/index.html?path=2.19/

Now set below code so selenium script will know the path of your binary

System.setProperty("webdriver.chrome.driver","./src\\lib\\chromedriver.exe");

So the code should be like this:-

System.setProperty("webdriver.chrome.driver","./src\\lib\\chromedriver.exe");
ChromeOptions options= new ChromeOptions();
options.addArguments("--no-startup-window");
//I tried this line also: options.addArguments("--silent-launch");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(capabilities);

Hope it will help you :)

Shubham Jain
  • 16,610
  • 15
  • 78
  • 125
1

I think the flag you are looking for is --headless This feature has just been implemented in chrome 57

--no-startup-window is used for hosting background apps, see this page and as mentioned in the other answers doesn't launch a window which is why the webdriver can't talk to it.

--headless does launch a window, but doesn't make it visible.

74nine
  • 838
  • 7
  • 13
  • Yes it does, it isn't documented that well yet, but it works (= – 74nine Apr 29 '17 at 13:41
  • One more thing, is it possible to download a file using headless chrome? – Pratibha Apr 29 '17 at 15:34
  • I don't see why not, but haven't tried it. so I would say, try! And let us know ;-) – 74nine May 02 '17 at 07:44
  • I am trying to download file which has link inside iFrameReport. Without headless mode, chrome is downloading the file but in headless mode, it si failing to find tag for iFrameReport. i verified in page_source, tag is there. – Pratibha May 05 '17 at 00:06
  • Ah that seems to be a known bug: http://stackoverflow.com/questions/42471151/chromium-chrome-headless-file-download-not-working. Too bad. [here](http://stackoverflow.com/questions/27942322/headless-browser-testing-with-download-functionality) are some solutions with other browsers, but you've probably already found those.. Good luck! – 74nine May 09 '17 at 06:57
0

I am using Selenium and trying to initialize the Chrome driver to start without a start up window.

According to Selenium GitHub (Strange error, chromedriver with --no-startup-window), Selenium requires JavaScript and Chrome window to work:

Much like --disable-javascript, the chromedriver will not work if you use --no-startup-window. It needs to launch a window to establish the connection with the AutomationProxy.

Lightman
  • 1,078
  • 11
  • 22