After encountering issues with the previous solution provided by @P.T. on Windows 7, I decided to experiment with his recommendations and eventually found a fix that worked for Windows users. Here is the modified approach tailored specifically for Windows 7.
STEP 1: Setup BASH and JQ and Verify Functionality on Your Windows Machine
- To start, you'll need to download bash:
For Windows 10
;
For Windows 7, download the latest version here:
https://sourceforge.net/projects/win-bash/files/shell-complete/latest/;
For Windows Server 2012 or any OS with Git already installed, locate bash.exe and sh.exe in either
C:\Program Files\Git\usr\bin
or C:\Program Files (x86)\Git\usr\bin
- Install bash - Extract the zip files to a directory for Windows 7
- Download
jq
() and install it in the same directory as bash
- Ensure to add your directory path (where bash zip files were extracted for Windows 7; for other OSes with Git, use the installation path) to the PATH system environment variable.
- Once both installations are completed and added to PATH, close all Webstorm and CMD windows before reopening them to proceed with your work.
- To verify the installation of bash, type
C:\git\> bash
in a command prompt window. It should display a bash cmd prompt like this: bash$
STEP 2: Implement Custom Files for Directing Chromedriver Debug Logs
Add the following files at the project's top level (where the protractor-conf.js file is located). These files allow custom debug switches for executing chromedriver.exe
This step is crucial as these switches are not directly accessible through protractor.conf.js via chromeOptions/args flags
chromedriver.cmd -- Source:
bash protractor-chromedriver.sh %*
protractor-chromedriver.sh -- Source:
TMPDIR="$(dirname $0)/tmp"
NODE_MODULES="$(dirname $0)/node_modules"
SELENIUM="${NODE_MODULES}/protractor/node_modules/webdriver-manager/selenium"
UPDATECONFIG="${SELENIUM}/update-config.json"
EXEFILENAME="$(cat ${UPDATECONFIG} | jq .chrome.last | tr -d '""')"
CHROMEDRIVER="${SELENIUM}/${EXEFILENAME##*'\\'}"
LOG="${TMPDIR}/chromedriver.$$.log"
fatal() {
echo >&2 "$0: ERROR: $*"
echo >"${LOG}" "$0: ERROR: $*"
exit 11
}
[ ! -x "$CHROMEDRIVER" ] && fatal "Cannot find chromedriver: $CHROMEDRIVER"
exec "${CHROMEDRIVER}" --verbose --log-path="${LOG}" "$@"
/tmp -- Create this directory at the project's top level (same location as the protractor.conf.js
file)
STEP 3: Update protractor.conf.js File
In the protractor.conf.js
, add the following line within the exports.config object:
exports.config = {
.. ..
chromeDriver: 'chromedriver.cmd',
.. ..
STEP 4: Run Your Tests
Your tests should now execute successfully, with any chrome driver log outputs stored in a file named chromedriver.???.log
under the tmp
directory within your project.
Important Notes
This script setup assumes Protractor (and its chrome driver) is installed and operated within the local node_modules directory of your project. If running Protractor/chromedriver globally, adjust the CHROMEDRIVER
variable inside protractor-chromedriver.sh
accordingly.
I hope this resolves your challenges.