Learning Automation: Selenium

BY: Mona Soni
www.monasoni.com

I have been the organizer of NYC Selenium meet up group now for almost 2 years and at various occasions people have come up to me and asked that they want to learn Selenium and where should they start. There are lot of online resources, tutorials and trainings available that can be used but sometimes more information is misleading and some people end up being lost. With this post I want to give a step by step guide and requirements to begin learning Selenium. If you think you know a step you may skip and jump onto next one.

What is Selenium?

Selenium is a test automation tool originally written by Jason Huggins as “JavaScriptTestRunner“ for the testing of an internal application.

You have not written code ever?

For those who are completely new to programming and want to use Selenium for test automation then Selenium-IDE is the tool which allows you to record your manual test steps and then replay them later.

You are not a programmer but understand basics?

Since you understand basics of programming you shouldn’t use Selenium-IDE as its difficult to maintain and extend the scripts, you should start with Selenium Webdriver. You would be required to use an IDE, you may use Eclipse to begin with. Depending on your programming level you may want to review Java basics.
Selenium Webdriver provides a browser-specific browser driver, which sends commands to a browser, and retrieves results. You may run your tests against browser of your choice. This post gives a step by step guide to write your fist test for a website. Uptil here were the basic steps that you need to do to write selenium tests for your application. But there is more to automation testing than just being able to add some scripts. Therefore we will look at the various aspects that need to be considered for creating a test suite for an actual application.


How to create a Selenium test suite?

When you are working on a project usually you would not be the only person writing tests and the life of those test could span in years. In such case your test script should be maintainable and scalable i.e. everybody on the team should be able to understand those tests, able to add more tests and refactor the tests. Therefore to establish a standard across the projects we use what is known as a test automation framework which is a set of assumptions, concepts, and practices that provide support for automated software testing.

A standard test automation framework has following components:

  • Configuration files: are used to configure the initial settings to run the test scripts and would include information about the test application, before and after scenarios, browser information and others

  • Test scripts: these are the main part of automation framework and are mainly selenium steps

  • Reusable functions: methods that can be reused in various test scripts

  • Test reporting: to get good feedback from test automation there should be good reporting mechanism

  • To begin with you should start with Testng, the documentation provided will help you to get started in writing the initial tests in testng framework.


Business driven tests

In recent years there has been lot of interest in the testing community to write better tests by using Behavior Driven Development. In BDD functional tests are written before writing the application code which helps in better design and tests. There are various frameworks that support BDD among which cucumber is widely accepted and used in combination with selenium. This was a very basic guide to learn selenium hope it helps out in your journey to test automation. Beyond this there are lot more resources online to explore.