Webdriver Manager: a node module

Craig N
4 min readMay 6, 2016

--

Webdriver manager started in protractor as a binary manager for selenium server and browser drivers. It is an awesome solution for setting up a selenium server for your end to end web tests. Webdriver manager was originally part of the Protractor project and has been extracted as its own node module.

Special thanks to Albert Pose for creating the initial fork of webdriver-manager. The pose/webdriver-manager is version <= 9. For versions 10 and greater, please refer to angular/webdriver-manager. If you there is a feature or issue, please create an issue.

Goals of webdriver manager

There are three goals of webdriver manager:

  1. Downloads the selenium server jar and browser drivers
  2. Runs the selenium server for end to end tests
  3. Manages downloaded versions

1. Downloading binaries:

Files are downloaded with the update command.

webdriver-manager updatewebdriver-manager: using global installed version 10.0.1
[14:46:56] I/downloader — selenium standalone: downloading version 2.53.0
[14:46:56] I/downloader — curl -o /opt/node_modules/webdriver-manager/built/lib/selenium/selenium-server-standalone-2.53.0.jar https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.0.jar
[14:46:56] I/downloader — chromedriver: downloading version 2.21
[14:46:56] I/downloader — curl -o /opt/node_modules/webdriver-manager/built/lib/selenium/chromedriver_2.21mac32.zip https://chromedriver.storage.googleapis.com/2.21/chromedriver_mac32.zip
[14:47:24] I/update — chromedriver: unzipping /opt/node_modules/webdriver-manager/built/lib/selenium/chromedriver_2.21mac32.zip
[14:47:25] I/update — chromedriver: setting permissions to 0755 for /opt/node_modules/webdriver-manager/built/lib/selenium/chromedriver_2.21

Why version is it downloading chrome version 2.21 and selenium server 2.53? These are all part of the config.json where Webdriver manager refers to the the cdn and downloads the webdriver version. It takes those values and generates a url to fetch those files.

// config.json
{
“webdriverVersions”: {
“selenium”: “2.53.0”,
“chromedriver”: “2.21”,
“iedriver”: “2.52.1”
},
“cdnUrls”: {
“selenium”: “https://selenium-release.storage.googleapis.com/",
“chromedriver”: “https://chromedriver.storage.googleapis.com/",
“iedriver”: “https://selenium-release.storage.googleapis.com/"
}
}

Great! But what if you wanted to run an older version of 2.52.0 of selenium server jar file and chromedriver 2.20? Previously, you would need to edit the config.json file, save it, and run the update command. When upgrading to a newer version, your config file would be overridden.

webdriver-manager update —-versions.chrome=2.20 --versions.standalone=2.52.0

For tests on Windows, iedriver can be downloaded with the ie flag or ie32 to download the 32-bit. From reviews the x64 version text entry is really slow and the 32-bit version is preferred.

webdriver-manager update —-ie —-versions.ie=2.52.0

2. Starting selenium standalone

Now that we have selenium standalone jar file and the browser driver, we can start up the selenium server with the start command.

webdriver-manager startwebdriver-manager: using global installed version 10.0.1
[13:20:43] I/start — java -jar /opt/node_modules/webdriver-manager/built/lib/selenium/selenium-server-standalone-2.53.0.jar -Dwebdriver.chrome.driver=/opt/node_modules/webdriver-manager/built/lib/selenium/chromedriver_2.21
[13:20:43] I/start — seleniumProcess.pid: 47966
13:20:43.808 INFO — Launching a standalone Selenium Server
Setting system property webdriver.chrome.driver to /opt/node_modules/webdriver-manager/built/lib/selenium/chromedriver_2.21
13:20:43.854 INFO — Java: Oracle Corporation 25.91-b14
13:20:43.854 INFO — OS: Mac OS X 10.11.4 x86_64
13:20:43.867 INFO — v2.53.0, with Core v2.53.0. Built from revision 35ae25b
13:20:43.947 INFO — Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match the current platform MAC
13:20:43.947 INFO — Driver provider org.openqa.selenium.edge.EdgeDriver registration is skipped:
registration capabilities Capabilities [{browserName=MicrosoftEdge, version=, platform=WINDOWS}] does not match the current platform MAC
13:20:43.948 INFO — Driver class not found: com.opera.core.systems.OperaDriver
13:20:43.948 INFO — Driver provider com.opera.core.systems.OperaDriver is not registered
13:20:43.949 INFO — Driver class not found: org.openqa.selenium.htmlunit.HtmlUnitDriver
13:20:43.950 INFO — Driver provider org.openqa.selenium.htmlunit.HtmlUnitDriver is not registered
13:20:44.048 INFO — RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
13:20:44.048 INFO — Selenium Server is up and running

Looking through the logs, the most important line to notice is:

java -jar /opt/node_modules/webdriver-manager/built/lib/selenium/selenium-server-standalone-2.53.0.jar -Dwebdriver.chrome.driver=/opt/node_modules/webdriver-manager/built/lib/selenium/chromedriver_2.21

That’s the basic magic that is starting up a selenium server. Similarly to downloading binaries, it starts the selenium server with the default configurations and can be overridden with similar options:

webdriver-manager start --versions.chrome=2.20 —-versions.standalone=2.52.0

3. Managing versions of binaries

Now that we have all these binaries downloaded, what files are installed and how about file maintenance? The status command will you what is currently downloaded and which ones are considered default values per the config.json file.

webdriver-manager statuswebdriver-manager: using global version 10.0.1
[15:58:56] I/status — selenium standalone versions available: 2.52.0, 2.53.0 [default]
[15:58:56] I/status — chromedriver versions available: 2.20, 2.21 [default]

For whatever reason, you have too many binaries downloaded and want to remove them. There is a clean command for that. It will go through your selenium directory and remove all the binary and zip files.

webdriver-manager cleanwebdriver-manager: using global version 10.0.1
[15:59:11] I/file_manager — removed chromedriver_2.20
[15:59:11] I/file_manager — removed chromedriver_2.20mac32.zip
[15:59:11] I/file_manager — removed chromedriver_2.21
[15:59:11] I/file_manager — removed chromedriver_2.21mac32.zip
[15:59:11] I/file_manager — removed selenium-server-standalone-2.52.0.jar
[15:59:11] I/file_manager — removed selenium-server-standalone-2.53.0.jar

What’s next?

Hopefully not much. Webdriver manager is a very simple binary manager. Here is the short short list of issues I hope to eventually get to:

  • Starting and stopping webdriver as a background process
  • Better logging options
  • Add better end to end tests

--

--

Craig N

Developer @Google. Will code for coffee, food, compliments. Video gamer, Seahawks fan, Husky alumni, Bourbon & Beer aficionado, DIY-er.