日志驱动程序日志文件的配置

时间:2020-10-25 14:14:29

标签: nightwatch.js

我已经在我的项目中实现了nightwatchjs,开始就在那里。但是,我不喜欢chrome和gecko驱动程序将日志文件放在我的根目录中。我非常希望将其移至日志记录位置。

    disable_error_log: true,
    desiredCapabilities: {
        silent: true,
        browserName: 'firefox',
        alwaysMatch: {
            acceptInsecureCerts: true,
            'moz:firefoxOptions': {
                args: []
            }
        }
    },
    webdriver: {
        start_process: true,
        server_path: GeckoDriver.path,
        cli_args: []
    }
},
chrome: {
    disable_error_log: true,
    desiredCapabilities: {
        silent: true,
        browserName: 'chrome',
        chromeOptions: {
            args: []
        }
    },
    webdriver: {
        log_path: false,
        start_process: true,
        server_path: ChromeDriver.path,
        cli_args: [
        ]
    }
}

现在,配置与上面相同。这里有两个日志记录问题:

  1. wat设置是用来打开还是关闭
  2. 您使用什么设置来更改日志的位置和/或文件名

2 个答案:

答案 0 :(得分:0)

我在Mac机器上运行Nightwatch,在我的nightwatch.conf.js文件中,我有一个具有log_path属性的Selenium对象。当前的路径为logs/,但我只是尝试删除该路径并将false用作路径,这对我有用。如果要关闭它,请将false作为log_path的路径,否则放入目录的名称(我的目录为logs/)。至于更改selenium-server.log文件的名称,我认为您不能更改它,除非有人创建了一个npm模块,该模块可以扩展Nightwatch。

selenium: {
        "start_process": true,
        "server_path": "bin/selenium-server-standalone-3.9.1.jar",
        "log_path": false,
        "port": 4444,
        "cli_args": {
            "webdriver.chrome.driver": this.chromePath
        }
    }

link for nightwatch docs

答案 1 :(得分:0)

我也有同样的问题。我通过在每个驱动程序的 webdriver 对象中设置 log_path 的值来解决这个问题。

您可以进行如下更改:

chrome: {
   disable_error_log: true,
   desiredCapabilities: {
       silent: true,
       browserName: 'chrome',
       chromeOptions: {
           args: []
       }
   },
   webdriver: {
       start_process: true,
       server_path: ChromeDriver.path,
       log_path:'log_folder',     // add this line to your every webdriver object.
       cli_args: [
       ]
   }
}

您可以通过将 log_path 设置为 false 来关闭 driverLog 生成。如果要指定某个特定文件夹来存储 driverLog 文件,则必须将 log_path 设置为所需位置。