Selenium Framework

April 27, 2019 Selenium

Selenium Framework:

The Selenium framework is a code structure to simplify code maintenance and improve code readability. A structure involves dividing the entire code into smaller pieces of code, which test a specific functionality. The code is structured in such a way that the “data set” is separated from the actual “test case” that will prove the functionality of the web application. It can also be structured so that the test cases that need to be executed are called (invoked) from an external application.

Why selenium structure is needed:

Selenium Framework is a code structure that helps facilitate code maintenance. In the case of a quality management system, it must be taken into account that, in most cases.

3 Commonly used Selenium frameworks are:

  • Data Driven framework
  • Keywork Driven framework
  • Hybrid framework

These structures will be discussed with a demonstration on this blog. But before proceeding, let me say why a Selenium structure needs to be in force and what benefits it will get from using them.

How to build a framework in selenium?

Every company runs on software and all software needs to be tested before being released to users. The automation software test is vital to launch efficient, effective and reliable software at a rapid pace. For this, you need automation structures. Automation structures allow less experienced testers to administer sophisticated tests in shorter development cycles. In this Test Automation Frameworks article, we will explore more about the concept of test structures.

Become a Selenium Certified Expert in 25Hours.

Benefits of the Selenium framework :

  • Greater code reuse
  • Better code readability
  • Greater portability
  • Reduced script maintenance

Data Driven framework:

The Data Driven Framework is one of the popular Automation Testing Framework in today’s market. The automated data-based test is a method in which the test data set is created on the Excel sheet and imported into the automation test tools to feed the software into the test.

As the test case is independent From the data set, we can easily modify the test case for a specific functionality without making bulk changes in your code. For example, if you want to modify the code for the login functionality, you can modify only this instead of also modifying any other dependent party in the same code.

Using the Apache POI With Selenium

WebDriverO WebDriver does not directly support the reading of Excel files. Thus, we use the Apache POI to read / write in any Microsoft Office document. Download the zip file or the tar file according to your need and place them together with the set of Selenium JARs.

The coordination between the main code and the data set will be taken care of by the TestNG Data Providers, which is a library that is part of the JAR files of the Apache POI. For demonstration purposes, I have created an Excel file called “LoginCredentials”, in which usernames and passwords have been stored in different columns.

Keyword Driven framework:

The video flow key is a type of functional automation testing Framework that is also known as a Table-Oriented test or Action Word-based test. The basic work of the Keyword Oriented Structure is to divide the Test Case into four different parts.

The benefit with the keyword-oriented structure is that you can easily control the functions you want to test. You can specify the methods that test the functionality of the application in the Excel file. Thus, only the names of the methods specified in the Excel will be tested.

Hybrid framework:

In the keyword-oriented structure, the keywords are written in some external files as the excel file and the java code calls that file and executes the test cases. The hybrid structure is a combination of keyword-oriented and data-driven structure. The hybrid structure is a technique in which we can make the best use of the structure or structures of the Data Driven & Keyword Driven Selenium. Using the examples shown above in this blog, we can build a hybrid structure by storing methods to execute in an Excel file (keyword-oriented approach) and pass these method names to the Java reflection class (data-oriented approach) in instead of creating an / Else loop in the “DriverScript” class.

 

Leave a Reply

Your email address will not be published. Required fields are marked *