Contact Us
Back

Test Automation With Selenium

Software testing plays an important role in delivering high quality software to the end user. With incorporating test automation using Selenium makes the life of developers and (especially) testers easier.

We incorporated selenium in our software development process about three years ago. Mentioned below is the proper way of writing selenium scripts in order to verify that the software has met all the specifications as laid out by the requirement document:

First: Analyze the require document and write test cases based on it. There should be at least one positive test and one negative test case for all functionality. There should one test that would verify the presence of each graphical user interface element.

Second: Write down code to automate the test cases. The code should only be written for those functionalities and user interface elements that must be delivered in the current build.

Third: Build a properties file that would be incorporated along with your selenium scripts. The properties file enables a tester not to change the test scripts’ code, only change the value of test data and selenium locators. Selenium locators such as CSS selectors and XPath selectors are used a lot to locate various user interface elements on the website. Also, with the properties file you just have change the test data and not the test script’s code.

Fourth: Build a TEST – JUNIT framework. JUNIT incorporates annotations and assertions. Annotations will allow you to control how the test script should run. Assertions will allow selenium to verify that the test case has passed or failed.

Fifth: Build a data driven framework. This frame allows you run test scripts against a lot of test data. For building a data driven framework you need build a file reader that will read Excel files. By using data driven framework the test scripts could be run against different data sets.

Refer to the below flow chart for the complete process for writing and executing selenium test scripts:

Figure 1: Selenium Test Scripts