Reputation: 25
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.
Upvotes: 2
Views: 2349
Reputation: 25
I found the answer, just install the jar as Windows Service...
Upvotes: -2
Reputation: 2507
See if the below steps work for you (answer from this thread):
Create a String array like this:
String[] phantomArgs = new String[] {
"--webdriver-loglevel=NONE"
};
Add the below line to your DesiredCapabilities
:
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, phantomArgs);
My config for PhantomJSDriver is something like this:
//set binary path of phantomJS driver
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setJavascriptEnabled(true);
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "drivers/phantomjs.exe");
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_PAGE_SETTINGS_PREFIX,"Y");
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, phantomArgs);
capabilities.setCapability("phantomjs.page.settings.userAgent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:16.0) Gecko/20121026 Firefox/16.0");
//intialize driver and set capabilties
PhantomJSDriver driver = new PhantomJSDriver(capabilities);
Right click on your project and choose Run As->Run Configurations->Arguments and add the VM argument -Djava.util.logging.config.file=logging.properties
to VM Arguments:
Click on Apply and then Run
Upvotes: 4