如何访问量角器测试的 chromedriver 日志 [英] How to access chromedriver logs for Protractor test

查看:46
本文介绍了如何访问量角器测试的 chromedriver 日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到 chromedriver 可以输出一个日志文件(https://sites.google.com/a/chromium.org/chromedriver/logging)

I have seen that chromedriver can output a logfile (https://sites.google.com/a/chromium.org/chromedriver/logging)

此页面显示了如何在直接执行 exe 时进行设置:

This page shows how to set this up when executing the exe directly:

chromedriver.exe --verbose --log-path=chromedriver.log

我不知道如何在 Protractor 中进行设置

I cannot figure out how to set this up in Protractor however

我目前的protractor.conf.js

require('babel/register');

exports.config = {
    framework: 'jasmine2',
    seleniumServerJar: './node_modules/protractor/selenium/selenium-server-standalone-2.45.0.jar'
};

来自 @alecxe 的回答如下量角器的浏览器设置文档 我尝试添加以下内容(有和没有 --s)但没有明显效果:

From @alecxe's answer below and protractor's browser setup docs I tried adding the following (with and without --s) but with no apparent effect:

    capabilities: {
        browserName: "chrome",
        chromeOptions: {
            args: [
                "--verbose",
                "--log-path=chromedriver.log"
            ]
        }
    }

我还尝试指定一个绝对路径 (log-path=/chromedriver.log),但也没有用.

I also tried specifying an absolute path (log-path=/chromedriver.log) which also didn't work.

推荐答案

您始终可以在一个单独的进程中启动您自己的 chromedriver 实例,并告诉 Protractor 连接到该实例.例如,如果您使用以下命令启动 chromedriver:

You can always start up your own instance of chromedriver in a separate process and tell Protractor to connect to that. For example, if you start chromedriver with:

chromedriver --port=9515 --verbose --log-path=chromedriver.log

然后你可以像这样使用 Protractor 的配置文件:

Then you could use a configuration file for Protractor like so:

   exports.config = {
     seleniumAddress: 'http://localhost:9515',
     capabilities: {
       'browserName': 'chrome'
     },
     specs: ['example_spec.js'],
   };

这篇关于如何访问量角器测试的 chromedriver 日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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