Prerequisite:
- Need to setup java properly in pc
- Need to setup Gradle
- Configure selenium
Let’s check if java is installed in our pc.
Go to cmd and hit following command:
> java -version
If Java is installed, then you will see the java version.
If Java is not installed before, then follow this tutorial to install java.
Now install Gradle. Download Gradle from here.
- Now extract the file and keep it in C:\Program Files\Java location
- Now go to environment variables and set GRADLE_HOME
3. Now set the Gradle path in variable value.
Now click on Ok button and go to cmd. Hit following command:
> gradle -version
If Gradle installed successfully, then you will see following output:
Configure selenium
- Now start IntelIJ and go to File>New>Project
- Select Gradle
3. Click on Next button and set project name and location
4. Click on Finish button
5. Apply automatic configuration.
6. Now go to build.gradle file and add following lines:
// https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.59'
// https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-remote-driver
compile group: 'org.seleniumhq.selenium', name: 'selenium-remote-driver', version: '3.141.59'
// https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-firefox-driver
compile group: 'org.seleniumhq.selenium', name: 'selenium-firefox-driver', version: '3.141.59'
// https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver
compile group: 'org.seleniumhq.selenium', name: 'selenium-chrome-driver', version: '3.141.59'
These lines are actually Gradle command that will fetch all selenium driver and browser dependencies. So you don’t have to install selenium jar files manually. Gradle is a dependency manager that will fetch all plugins for the required version.
Now click on Gradle tab and click on import icon.
Now all dependencies has been imported. It’s ready to start writing code.
We will write our first selenium script in next tutorial.
[…] Check Selenium configuration here. […]