Search code examples
javaseleniumphantomjsghostdriver

Java And GhostDriver : Hide Console and Logs


I try to hide the console and the log of GhostDriver in java...

- Windows 7.
- JDK is in 1.7.0_75 version.
- PhantomJS 1.9.7 is include with it path.
- GhostDriver 1.1.0 is include in an Eclipse Java SE Project.
- Selenium 2.43.1 is include in an Eclipse Java SE Project.

Is there a way?

I tried "--webdriver-loglevel=OFF" and "--webdriver-loglevel=NONE" in cli_args but it doesn't works...

I tried java -jar myJar.jar > myFile.txt but it doesn't works...

Is there others ways or may be an error?

An example of the code :

    WebDriver driver;
    DesiredCapabilities dCaps;
    dCaps = new DesiredCapabilities();
    dCaps.setJavascriptEnabled(true);
    dCaps.setCapability("takesScreenshot", true);
    dCaps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, new String[] {"--ignore-ssl-errors=true", "--ssl-protocol=tlsv1", "--web-security=false", "--webdriver-loglevel=OFF", "--webdriver-loglevel=NONE"});
    dCaps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, phantom);
    driver = new PhantomJSDriver(dCaps);

And the logs (with VM arguments) :

   mai 18, 2015 2:09:48 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
   INFOS: executable: C:\Users\212428788\workspace\BigBrowser\phantomjs-1.9.7-windows\phantomjs.exe
   mai 18, 2015 2:09:48 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
   INFOS: port: 48921
   mai 18, 2015 2:09:48 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
   INFOS: arguments: [--ignore-ssl-errors=true, --ssl-protocol=tlsv1, --web-security=false, --webdriver-loglevel=OFF, --webdriver-loglevel=NONE, --webdriver=48921, --webdriver-logfile=C:\Users\212428788\workspace\BigBrowser\phantomjsdriver.log]
   mai 18, 2015 2:09:48 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
   INFOS: environment: {}
   PhantomJS is launching GhostDriver...

Thank you very much.


Solution

  • I found the answer, just install the jar as Windows Service...