Setting up your Selenium Automation Project by yourself

Though it sounds so typical — this is for the beginners. Let’s get back to work with less talk!!

Setting up the prerequisites...

  • Download JDK from Oracle which suits your OS.
  • Run the .exe file and continue the wizard till finish.
  • Open Control panel → System and Security → Advance system Settings → Advance tab → Click ‘Environment Variables’.
  • Add ‘JAVA_HOME’ as a system variable.
  • Edit the ‘Path’ system variable by adding the “%JAVA_HOME%\bin”.
  • To test the configuration — open Command prompt and hit “echo %JAVA_HOME%” and “javac -version”.

Setting up Maven is also not that hard…

  • Download the Binary zip
  • Again open Control panel → System and Security → Advance system Settings → Advance tab → Click ‘Environment Variables’.
  • Add “MAVEN_HOME” as a system variable.
  • Update “Path” variable with the %MAVEN_HOME%\bin
  • For verification, open command prompt and run “mvn -version

Next step, there are many supporting IDEs for test automation. Most commonly, download Eclipse setup or IntelliJ setup (community edition-it’s free) and run the setup. Successful installation should allow to a successful launch.

Here you go!!! but wait, we need to our automation project.

Selenium, being the most popular browser automation tool and the easiest way of using the WebDriver — a powerful API that builds on top of Selenium and allows calls to automate.

Having quoted that, let’s create a simple project for site.

  • Open IntelliJ and go to ‘File’ → ‘New’ → ‘Project’
  • Select ‘Maven’ and set the ‘Project SDK’ to the java version installed and click ‘Next’
  • Add a ‘GroupId’ and ‘ArtifactId’ and click ‘Next’.
  • Give a project name and select the location and hit ‘Finish’.

Next, you need to add Selenium Chrome Driver, TestNG, and Selenium Support dependencies to the pom.xml file.

Now, we need to create our pageObjects and tests.

Always maintain the project structure as shown below.

Create a package ‘pageObjects’ under src/main/java → add a class ‘HomePage’ which will have all the required pageObjects.

Create a package ‘tests’ under src/test/java → add a class ‘Sample test’ which will have our test.

Add ‘chromedriver.exe’ to the src/main/resources location.

  • To the ‘HomePage’ and ‘LoginPage’ pageObjects — add some objects and methods to interact with the webpage.
  • Next, construct the test case ‘SampleTest’
  • Right-click on the test case and click ‘Run’ to execute.

If there are no errors, your test case should be passed and you should be able to see the output in the console.

Yippee!! it worked. If you have trouble — please visit my GitHub repo.

Keep in mind — this automation project can be enhanced in many ways but I think this is enough for a fresher to begin with. Planning to post more on my experiments — stay tuned!!

Happy Automating!! :)

Senior Quality Engineer at Wiley Global Technology | MSc in IT | BSc in IT | ISTQB — CTFL