9

I'm using PhantomJS + Selenium in my application. When I initialize PhantomJS, a console pops up on the screen. I would like to hide this console before it pops up. I have searched for an answer, and I found this:

 var service = PhantomJSDriverService.CreateDefaultService(Environment.CurrentDirectory);
            service.WebSecurity = false;
            service.HideCommandPromptWindow = true;
            var driver = new PhantomJSDriver(service);

The code above hides the console, but the problem is that when the console is hidden my Windows application loses the focus. So, it stops working while PhantomJS console is working. I need to hide the console and make my application work with PhantomJS at the same time.

Does anyone know how can I do that?

Brian Rogers
  • 125,747
  • 31
  • 299
  • 300
Tiago Castro
  • 155
  • 1
  • 9
  • 1
    possible duplicate of [How can I start PhantomJS + Selenium window in background?](http://stackoverflow.com/questions/26133336/how-can-i-start-phantomjs-selenium-window-in-background) – Artjom B. Oct 03 '14 at 06:08

1 Answers1

18

I am using this thing all the time works fine.

var driverService = PhantomJSDriverService.CreateDefaultService();
driverService.HideCommandPromptWindow = true;

var driver = new PhantomJSDriver(driverService);
Evaldas B
  • 2,464
  • 3
  • 17
  • 25
  • Do you know if there is something similar for Python? I couldn't find anything in the API documentation. I am running a task in Windows Task Scheduler that runs a Python script using the PhantomJS web driver, but the phantom.js window keeps popping up every time, and I would like to hide it. – Evan LaHurd Feb 07 '16 at 23:05