如何用selenium更改phantomjs的logfile路径?

时间:2014-09-12 09:13:38

标签: javascript selenium phantomjs webdriver-io

当使用phantomjs和selenium时,我想更改默认的--webdriver-logfile参数,即selenium传递给phantomjs。我该怎么做?

selenium log中的相应行:

11:06:06.960 INFO - arguments: [--webdriver=14380, --webdriver-logfile=<ROOT PATH DELETED HERE>/phantomjsdriver.log]

在coffeescript中点燃phantomjs:

webdriverio = require 'webdriverio'

module.exports.World = World = (next) ->
  @browser = webdriverio.remote({ desiredCapabilities: {
    browserName: 'phantomjs'
    "phantomjs.binary.path": "node_modules/phantomjs/bin/phantomjs"
  }})
  .init()

next()

1 个答案:

答案 0 :(得分:0)

我正在寻找几个小时但找不到答案,因此我在selenium调用的phantomjs文件中将其入侵。这不是一个合适的解决方案,但可以胜任。

args = args.map(function(str) {
 if(str.search('-webdriver-logfile') != -1 ) {
    console.log('Replacing default webdriver log with null in phantomjs');
    return str.replace(/--webdriver-logfile=.*$/i,"--webdriver-logfile=/dev/null")
 }
 return str;
 });