How to Install and Update WebDriver Manager for Selenium and Protractor
A complete guide to managing Selenium WebDriver binaries using WebDriver Manager. Learn how to install, update, and troubleshoot driver issues in your automation projects.
Introduction
🎯 Quick Answer
To install WebDriver Manager, run npm install -g webdriver-manager for global access or npm install webdriver-manager --save-dev for project-specific use. To download or update the actual browser drivers (like ChromeDriver), execute the command webdriver-manager update. This ensures you have the latest binaries required to launch and control browsers during your automated tests.
WebDriver Manager is a helper tool that manages the browser driver binaries (like ChromeDriver, GeckoDriver, and IEDriver) and the Selenium Server standalone JAR file. It simplifies the process of keeping these essential components up to date, which is critical for stable test execution.
📖 Key Definitions
- WebDriver Manager
A command-line tool that downloads and manages the binaries required for Selenium WebDriver to interact with different browsers.
- Binaries
Executable files (e.g.,
chromedriver.exe) that act as a bridge between your automation scripts and the physical browser.- Selenium Server
A server that allows you to run tests on remote machines or manage multiple browser instances from a central point.
- Protractor
An end-to-end test framework for Angular and AngularJS applications that relies heavily on WebDriver Manager.
Why is WebDriver Manager Necessary?
Browsers like Chrome and Firefox update frequently. When a browser updates, its corresponding WebDriver binary often needs an update as well to remain compatible. Manually downloading and placing these files in the correct folders is tedious and error-prone. WebDriver Manager automates this entire lifecycle.
🚀 Step-by-Step Implementation
Open Your Terminal
Open your command prompt or the integrated terminal in Visual Studio Code.
Install the Package
Install the tool globally to use it anywhere:
npm install -g webdriver-manager
Or install locally in your project: npm install webdriver-manager --save-dev
Download Drivers
Run the update command to fetch the latest versions of ChromeDriver, GeckoDriver, and the Selenium Server JAR:
webdriver-manager update
Verify the Binaries
Check the selenium folder created by the tool to ensure the .exe and .json files are present.
Start the Server (Optional)
If you need a standalone Selenium Server, run:
webdriver-manager start
Common Errors & Best Practices
⚠️ Common Errors & Pitfalls
- Version Mismatch
If your Chrome browser is version 120 but you have ChromeDriver 118, your tests will fail to start. Always run
webdriver-manager updateafter a browser update. - Network/Proxy Blocks
Corporate firewalls often block the download of
.exefiles. You may need to configure proxy settings:webdriver-manager update --proxy http://your-proxy:port. - Permission Denied
On macOS/Linux, global installation might require
sudo. However, it's better to fix your npm permissions or use a local installation.
✅ Best Practices
- ✔Install WebDriver Manager locally in your project's
devDependenciesto ensure all team members use the same version. - ✔Add
webdriver-manager updateto yourpackage.jsonscripts or as apostinstallhook to automate driver updates. - ✔If a specific driver version is required, use flags like
--versions.chrome 114.0.5735.90to pin that version. - ✔Regularly clean old binaries to save disk space using the
--cleanflag during updates.
Frequently Asked Questions
Do I need this if I use directConnect?
Yes. Even with directConnect: true in Protractor, you still need the binaries downloaded by WebDriver Manager.
Where are the files downloaded?
By default, they are in node_modules/webdriver-manager/selenium/ for local installs or in your global npm folder for global installs.
Can I update only ChromeDriver?
Yes, use the flag --gecko false --ie false to skip other drivers and only update Chrome.
Conclusion
WebDriver Manager is an indispensable tool for any Selenium or Protractor-based automation project. By automating the management of browser drivers, it removes a significant source of "flaky tests" and environment setup headaches, allowing you to focus on writing effective test cases.
📝 Summary & Key Takeaways
WebDriver Manager is a critical utility for managing the lifecycle of browser driver binaries and Selenium Server components. The installation involves adding the webdriver-manager package via npm, followed by executing the update command to synchronize local binaries with the latest browser versions. While global installation offers convenience, local project-based installation is recommended for team consistency. Success in using this tool depends on regular updates to match browser versions and proper handling of network or permission constraints. By integrating WebDriver Manager into the development workflow, teams can ensure a stable and reliable foundation for their automated testing suites.
Share it with your network and help others learn too!
Follow me on social media for more developer tips, tricks, and tutorials. Let's connect and build something great together!