In the following tutorial, we’re going to understand how to setup a basic environment for getting started with automation using selenium with java programming language.
Before we begin, we need to have performed the following steps:
- Install java on your computer.
- For Windows systems, java should be pre installed. If you’re having any issues, follow this link.
- For Linux systems, type the following command in the terminal :
sudo apt-get install openjdk-8-jdk
- Install eclipse IDE from eclipse.org. Make sure you have java installed before you try installing eclipse.
- Download the selenium Jar files from seleniumhq.org.
Now we’ll begin configuring Eclipse IDE for working with selenium webdriver.
Open up Eclipse and Create a new Java project in the Eclipse workspace.
Right click on the newly created project and create a new package with the src folder, by navigating New > Package, and then give name of the package, then click on finish button.
Create a new Java class inside the new package by right-clicking on it and then selecting - New > Class, and then name the class. Remember to follow the basic java convention for naming a class file, i.e., all class names should start with Capital letter.
Now put selenium WebDriver’s jar files into Java Build Path by :
- Right-click on the project and navigate to ‘Build Path’ > ‘Configure Build Path…‘.
- Click on the Libraries tab, and then click on “Add External JARs…“.
- When you click on “Add External JARs…” a pop-up window opens up. Select the JAR files which we downloaded initially.
- After selecting jar files, click on OK button. Select all jar files and add. Finally click on ‘Apply and Close’ button.
With this done, we are ready to start coding the selenium automation scripts. In the next post we’ll begin to code and learn how to trigger browsers and open different webpages/websites.
Keep coding! Have fun.