Selenium Introduction

Selenium WebDriver an open source framework which has been widely used these days for automating web browsers which also allows us to integrate with other tools to develop automated tests.

Why Selenium

Selenium is probably the best option for automated testing of Websites today. It is becoming increasingly popular and it is the first choice of automation testers as well as organizations for automating the testing of Web-based applications for both the GUI as well as the functionality.

How to Set up

Download the latest java jdk from here
Download the latest build for eclipse from here
Download the latest apache maven from here

You should have installed Java in your system.

In order to use Selenium to automate your tests using a test framework, we need an Integrated Development Environment (IDE) to add few dependencies in order to build a testing framework. I would love to use Eclipse which is most widely used IDE. We also have IntelliJ IDEA and NetBeans though. By using this, we could set up our test environment so quick using Maven or by adding jars.

Wait what is Maven

Apache Maven is used to define project structure, dependencies, build, and test management. We can use Eclipse and Maven to build your test framework by just few clicks. The main benefit of using Maven is that you can get all the Selenium library files and their dependencies by configuring the pom.xml file. Maven automatically downloads the necessary files from the repository while building the project.

How to install Java & Maven

1. Install the downloaded Java JDK and set the JAVA_HOME environment variable to point to the path where Java JDK was installed (on a windows 7 system the environment variables can be accessed by right clicking your Computer, select Properties, then Advanced system settings, then press the Environment Variables button)

Environment Variables

2. Unpack the downloaded maven archive, then set the MAVEN_HOME env variable to point to the path where maven was installed

Environment Variables

3. Set the Path variable to both: %JAVA_HOME%\bin and %MAVEN_HOME%\bin

Path variable

4. To check everything is ok, open a command prompt and type: java –version to see the current version of the java jdk installed and also mvn to see if the command is recognized by the system

Command Prompt

5. Unpack the downloaded eclipse archive to a local directory and create a shortcut for it on Desktop and start it

6.  You need to choose a directory for your workspace. This workspace would be the place where all your code will be stored

7.  Go to Help -> Eclipse Marketplace and search for m2eclipse, then choose Maven Integration for Eclipse

Eclipse Marketplace

8.    Click Next on the following screen

Eclipse Marketplace

9.    Accept the license and click Finish

Eclipse Marketplace

10.    Restart eclipse

Restart eclipse

That’s it on the restart, your eclipse should have Maven installed in it. If you would like to check it then click on Help -> Install New Softwares -> What’s already installed.
You should see m2e added.