4

I'm using selenium + phantomjs in my application, but I want to start my application, selenium and phantomjs window in background. How can I do it?

I tried:

PhantomJSOptions options = new PhantomJSOptions();
options.AddAdditionalCapability("start-maximized", false);
IWebDriver driver = new PhantomJSDriver(Environment.CurrentDirectory + @"\drivers", options);
Artjom B.
  • 61,146
  • 24
  • 125
  • 222
Tiago Castro
  • 155
  • 1
  • 9
  • Ohh Sorry.. When I start my application I want to start phantomjs in background. – Tiago Castro Oct 01 '14 at 19:26
  • I'm not sure I understand your problem. PhantomJS is headless, so there is no window that is opened. What window are you talking about? – Artjom B. Oct 01 '14 at 21:59
  • When I declare a webdriver with type as Phantomjs, a new Console open in the screen.I have searched about it, and I can hide this console but when I do that, my application stop working until phantomjs stop. – Tiago Castro Oct 01 '14 at 22:03
  • possible duplicate of [Selenium Webdriver PhantomJS C# always opens a cmd window](http://stackoverflow.com/questions/20711407/selenium-webdriver-phantomjs-c-sharp-always-opens-a-cmd-window) – Artjom B. Oct 01 '14 at 22:07
  • No, My problem is like this one,I can hide the console application but when I hide, like I said, my application stop working..How can I fix that? – Tiago Castro Oct 01 '14 at 22:16
  • So you tried it already with `driverService.HideCommandPromptWindow = true;` and it didn't work? – Artjom B. Oct 01 '14 at 22:19
  • Yes, I tried it. It hide the Console. But My application does not focus. My application stop working until phantomjs do all what it have to do. – Tiago Castro Oct 01 '14 at 22:32

1 Answers1

6
var serviceJs = PhantomJSDriverService.CreateDefaultService(phantomPath);
serviceJs.HideCommandPromptWindow = true;

Instance = new PhantomJSDriver(serviceJs);
Andrew_STOP_RU_WAR_IN_UA
  • 9,318
  • 5
  • 65
  • 101