In this chapter, we will install Selenium 4.
We will also install TestNG and WebDriverManager as dependencies to the pom.xml file.
To begin, we go to mvnrepository.com, then search for “Selenium 4”. There are different options for Selenium.
We see Selenium Java, Selenium API, Selenium Server, Selenium Support, and Selenium for the drivers — Chrome driver, Firefox Driver, Remote Driver, HtmlUnit Driver, IE Driver, and RC Java Client Driver.
If we select Selenium Java, then we include the drivers as part of the dependency, except for HtmlUnit Driver and RC Java Client Driver.
I'm going to select Selenium Java as the dependency, and we see version 4.0.
It's optional to include a comment, so we'll remove the comment. Copy this, then go to the pom.xml file. Next, add dependencies
.
Within dependencies
paste the Selenium Java dependency
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.0.0</version>
</dependency>
</dependencies>
To show you what’s inside a selenium Java, control is what you click. Then hover over “selenium-java” and click “selenium-java”.
And we see the drivers for Selenium — Remote Driver, Opera Driver, IE driver, Firefox Driver, Edge Driver, Dev Tools and Chrome Driver should be here also. Yes, and API.
Now I'm going to go back to mvnrepository.com, then search for “TestNG”.
We select TestNG and the latest version is version 7.4 (as of this recording).
Copy the dependency, go to our pom.xml file and I will paste TestNG under Selenium Java.
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.4.0</version>
<scope>test</scope>
</dependency>
Now the last dependency is WebDriverManager. Search for “WebDriverManager”, and we see version 5.03 as the dependency (at this time).
WebDriverManager is a dependency that automatically manages our drivers for Selenium. At the top it shows “automated driver management”.
So, I'm going to select 5.03, copy, then go back to our pom.xml file and paste the dependency.
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.0.3</version>
</dependency>
Now that's it for the dependencies.
NOTE
If you have a red line under your version, just hit control + shift + O to load the Maven changes. Or you can reload all Maven projects.
In the next chapter, we will look at W3C WebDriver protocol.