在Java中更改PhantomJS日志文件的路径 [英] Change path for the logfile of PhantomJS in java
本文介绍了在Java中更改PhantomJS日志文件的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法弄清楚如何为PhantomJS更改日志文件的路径. 我尝试:
I cannot figure out how I can change path for logfile for PhantomJS. I try with:
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true);
caps.setCapability("takesScreenshot", false);
caps.setCapability(
PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_CLI_ARGS,
new String[] { "--logfile=/home/ant/Document/phantomjsdriver.log" });
caps.setCapability(
PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
path);
还有:
ArrayList<String> cliArgsCap = new ArrayList<String>();
cliArgsCap.add("--logfile=/home/ant/Document/phantomjsdriver.log");
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true);
caps.setCapability("takesScreenshot", false);
caps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS,cliArgsCap);
但是现在它不起作用.
推荐答案
在查看这就是我的操作方式,有点笨拙,但对我有用...希望这会有所帮助:
So here is how I did it, is a little bit hacky but it worked for me...hope this helps:
DesiredCapabilities dcap = new DesiredCapabilities();
File logfile = new File("ABSOLUTE_PATH_TO_YOUR_LOG_FILE");
String[] phantomArgs = [ "--webdriver-loglevel=DEBUG" ]
PhantomJSDriverService pjsds = new PhantomJSDriverService.Builder()
.usingPhantomJSExecutable(f)
.usingAnyFreePort()
.withProxy(proxy)
.usingCommandLineArguments(phantomArgs)
.withLogFile(logfile)
.build();
PhantomJSDriver pdriver = new PhantomJSDriver(pjsds, dcap);
这篇关于在Java中更改PhantomJS日志文件的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文