如何使用Selenium更改phantomjs的日志文件路径? [英] How can I change logfile path of phantomjs with selenium?

查看:272
本文介绍了如何使用Selenium更改phantomjs的日志文件路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当将phantomjs与硒一起使用时,我想更改默认的--webdriver-logfile参数,即硒传递给phantomjs.我该怎么做?

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?

硒日志中的相应行:

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

在coffeescript中启动phantomjs:

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()

推荐答案

我已经找了几个小时,却找不到答案,因此我在selenium调用的phantomjs文件中修改了它.这不是一个适当的解决方案,但可以完成任务.

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

这篇关于如何使用Selenium更改phantomjs的日志文件路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆