How can I change logfile path of phantomjs with selenium?

杀马特。学长 韩版系。学妹 提交于 2019-12-06 04:38:57

问题


When using phantomjs with selenium, I would like to change the default --webdriver-logfile parameter, that selenium passes to phantomjs. How can I do it?

The corresponding line in selenium log:

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

Firing up phantomjs in coffeescript:

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:


I was looking for few hours and could not find the answer, therefore I have hacked it in the phantomjs file that is called by selenium. This is not a proper solution but does the job.

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;
 });


来源:https://stackoverflow.com/questions/25804745/how-can-i-change-logfile-path-of-phantomjs-with-selenium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!