

NPM requires this file to install the dependencies and plugins used to build the project along with running the tests. Once we have installed the Selenium libraries and set the path for the browsers, we need to add the package.json file to the project root directory. Mac and Linux users need to add a driver path to the $PATH variable in the shell.

Windows users may add the driver path to the PATH variable under environment variables. The drivers can be downloaded from the Downloads page and the links can be found under the “Browsers” section on the page. npm install -g selenium-webdriverĪdditionally, to run the tests on the browsers (Chrome, Firefox and IE etc), browser drivers need to be downloaded and set in the system path. Using the below command we will install Selenium with npm package manager on your machine. To verify the installation, use the below two commands node -v npm -vīoth should give the current version installed as an output.

Install NodeJs and NPMĪs a prerequisite, NodeJs needs to be downloaded and installed on the machine. You can download and manage the Selenium JavaScript bindings using npm. We can search for a library and copy and paste the dependency into our pom.xml file to download them.įor example, Selenium 4 can be downloaded using maven by adding the dependencies in pom.xml as shown in the below sample:

Maven Central Repository is the place where all the dependencies/libraries for all versions can be found. Maven looks for a pom.xml file for information on project, configuration, dependencies and plugins etc. However, if you are not using the plugin, you can install Maven manually. Maven is also available with the Java IDEs (IntelliJ, Eclipse, etc) as a plugin. Maven is a build and dependency management tool for Java based application development which helps with complete build lifecycle management. There are various Java build tools available to manage the build and dependencies the most popular and widely used ones are Maven and Gradle. However, you only need to choose one approach. The Selenium Java binding can be set up in two different ways: via build tools, or manually. How to Install Selenium 4īefore beginning, make sure Java is installed on your machine and the JAVA_HOME environment variable is set in your system path.
