Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ChromeDriver console application hide

Tags:

I have created a player which will automate chrome using selenium and ChromeDriver in C#. It's working fine.

Issue what I am facing is, when it creates an object for ChromDriver, it will start ChromeDriver application, which gets pop up and then Chrome will load. It's perfect as that application is loading that chrome for me.

Is there anyway, that I can open that ChromeDriver hidden?

like image 797
Sanket Shah Avatar asked Jul 16 '12 09:07

Sanket Shah


People also ask

How do I hide a window in Selenium?

We can hide the Firefox window in Selenium webdriver. This can be done by making the browser headless. We shall achieve this with the FirefoxOptions class. We shall then create an object option of that class.

How do I remove Chromedriver exe?

First end the process of chromedriver.exe from Task Manger, then Delete the chromedriver.exe from your project bin file and check whether Selenium. WebDriver. ChromeDriver package installed or not, If it's not installed you should installSelenium.

How do I run Chromedriver in headless mode?

Post version 59, Chrome supports headless execution. ChromeOptions class is utilized to modify the default characteristics of the browser. The addArguments method of the ChromeOptions class is used for headless execution and headless is passed as a parameter to that method.

Can websites detect Chromedriver?

Can a website detect when you are using selenium with chromedriver? Yes. Also, what I haven't experimented with is older selenium and older browser versions - in theory, there could be something implemented/added to selenium at a certain point that Distil Networks bot detector currently relies on.


2 Answers

No, there is no way to hide the console window of the chromedriver.exe in the .NET bindings without modifying the bindings source code. This is seen as a feature of the bindings, as it makes it very easy to see when your code hasn't correctly cleaned up the resources of the ChromeDriver, since the console window remains open. In the case of some other languages, if your code does not properly clean up the instance of ChromeDriver by calling the quit() method on the WebDriver object, you can end up with a zombie chromedriver.exe process running on your machine.

like image 41
JimEvans Avatar answered Sep 18 '22 03:09

JimEvans


Modifying source code in WebDriver\DriverService.cs is not necessary for this in latest WebDriver. You just need to instantiate ChromeDriverService and set HideCommandPromptWindow to true and then instantiate ChromeDriver by that service and ChromeOptions. I am giving C# code example below

var chromeDriverService = ChromeDriverService.CreateDefaultService();
chromeDriverService.HideCommandPromptWindow = true;
return new ChromeDriver(chromeDriverService,  new ChromeOptions());
like image 73
Rasel Avatar answered Sep 18 '22 03:09

Rasel