I have seen that chromedriver can output a logfile (https://sites.google.com/a/chromium.org/chromedriver/logging)
This page shows how to set this up when executing the exe directly:
chromedriver.exe --verbose --log-path=chromedriver.log
I cannot figure out how to set this up in Protractor however
My current protractor.conf.js
require('babel/register');
exports.config = {
framework: 'jasmine2',
seleniumServerJar: './node_modules/protractor/selenium/selenium-server-standalone-2.45.0.jar'
};
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"
]
}
}
I also tried specifying an absolute path (log-path=/chromedriver.log
) which also didn't work.
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
Then you could use a configuration file for Protractor like so:
We use a shell script to add chromedriver logging, among other checks. You can then point protractor at the shell script:
protractor config:
bin/protractor-chromedriver.sh
In case you use webdriver-manager: webdriver manager has the
chrome_logs
option (you can find it in its source code (inopts.ts
oropts.js
in the compiled code)), so you can use it something like:Since, the previous answer by @P.T. didn't work for me on Windows 7, I started with his suggestions and got it working on Windows. Here is a working solution for Windows 7 users.
STEP 1: Install BASH and JQ and confirm they are working on your Windows box
bash.exe
andsh.exe
installed atC:\Program Files\Git\usr\bin
orC:\Program Files (x86)\Git\usr\bin
already )jq
(https://stedolan.github.io/jq/) and install it in the same directory location asbash
bash
is actually installed by simply typing it on a windows command promptC:\git\> bash
. Doing so should produce a bash cmd prompt like thisbash$
STEP 2: Add Custom Files for Redirecting Chromedriver to user Debug Logging
Add the following files to the top level of the project (wherever your protractor-conf.js is located). These files allow us to add custom debug switches to the chromedriver.exe execution.
Note that this is necessary because these switches are not exposed through protractor and cannot be done directly in the
protractor.conf.js
file via the chromeOptions/args flags as you would normally expectchromedriver.cmd -- exact source shown below:
protractor-chromedriver.sh -- exact source shown below:
/tmp -- create this directory at the top level of your project (same as the location of the
protractor.conf.js
file.STEP 3: Update protractor.conf.js file.
In the
protractor.conf.js
file, add the following line as a property in the exports.config object. As in:STEP 4: Launch your tests
your test should now run and if the chrome driver outputs any log information it will appear in a file called
chromedriver.???.log
in thetmp
directory under your project.Important caveats
This script set up assumes you install and run protractor (and the chrome driver under it) within the local node_modules directory inside your project. That is how I run my code, because I want it complete self-contained and re-generated in the build process/cycle. If you have protractor/chromedriver installed globally you should change the
CHROMEDRIVER
variable within theprotractor-chromedriver.sh
file to match your installation of protractor/chrome driver.hope that helps.
According to the
protractor
's source code,chromedriver
service is started without any arguments and there is no direct way to configure the arguments. Even though the chromedriver's Service Builder that protractor uses actually has an ability to specify the verbosity and the log path:Old (incorrect) answer:
You need to set the chrome arguments:
See also:
If you're using the
seleniumServerJar
, inprotractor.conf.js
set the logfile path to wherever you want it to write the file:If you're using
webdriver-manager start
to run a local selenium server, you'll need to edit thewebdriver-manager
file: