top of page
hand-businesswoman-touching-hand-artificial-intelligence-meaning-technology-connection-go-

Hybrid Driven Framework


Hybrid Driven Framework is a combination of data-driven and keyword-driven frameworks. This framework uses different keywords and data sets, where the inputs and functions list are stored in separate files. Keywords are maintained in a separate Java class file and test data can be maintained either in a properties file or an excel file or can use the data provider of a TestNG framework.

Let’s check out some additional features of the hybrid test automation framework:

· It allows ease of installation and maintenance.

· In a hybrid test framework, the consistency of test automation is being implemented by defining standards

· Hybrid allows the user in tool independence by implementing your framework as separate software

· A hybrid Framework can be created and used to automate any application.

· It will reduce the man-hours spent in scripting the automation code since a framework once created can be used to automate multiple applications.


To design the framework we need to go through step by step process.


Hybrid Driven Framework structure




This is the overall framework structure.

There are three different classes to work with the framework. These are reusable components, meaning these files can be used for every test case. That’s why it is called common resources.

1. Implementation/Development part

· Page Object: For every page, we must create a page object class.

· Utility class: Read config. jave, Reporting.java

· Config files: Pom.xml, Extended config.xml log4.

· Test Cases: Base class.

2. Execution Part

· TestNG.xml

· Pom.xml

3. Continuous Integration Part

· Maven (Ran.bat)

· Jenkins.

1. In the Implementation part we can do the following activities:



2. In the Execution Part we will do the following activities:



3. In the Continuous Integration Part we will do the following activities:



Before going to deep dive into Hybrid Framework we should be familiar with some of the core components like :

  • Maven,

  • Pom,

  • TestNG,

  • Cucumber (if you are using Cucumber in your project) and

  • Jenkins.


Maven: Maven is a popular open-source build tool developed by the Apache Group to build, publish, and deploy several projects at once for better project management. Maven can easily handle the entire lifecycle of a project which can include code generation, compilation, testing, validation, packaging, and much more. It works in phases rather than tasks and makes the build management process much easier.


POM.XML: A Project Object Model or POM is the fundamental unit of work in Maven. The pom. XML file contains information of project and configuration information for the maven to build the project such as dependencies, build directory, source directory, test source directory, plugin, goals, etc.


TestNG: TestNG makes automated tests more structured, readable, maintainable, and user-friendly. It provides powerful features and reporting. Its high-end annotations like data provider, grouping, and parametrizing. t covers all classifications of test automation like Unit testing, Functional testing, End-to-End, and integration testing.

TestNG annotations play a vital role in TestNG. TestNG Annotations are used to control the next method to be executed in the test script. TestNG annotations are defined before every method in the test code. In case any method is not prefixed with annotations, it will be ignored and not be executed as part of the test code. To define them, methods need to be simply annotated with ‘@Test‘.

Types of TestNG Annotations

  • BeforeSuite.

  • BeforeTest.

  • BeforeClass.

  • BeforeMethod.

  • Test Case.

  • AfterMethod.

  • AfterClass.

  • AfterTest.

Let’s explore how these methods work.

· @BeforeMethod: This will be executed before every @test annotated method.

· @AfterMethod: This will be executed after every @test annotated method.

· @BeforeClass: This will be executed before the first @Test method execution. It will be executed only one time throughout the test case.

· @AfterClass: This will be executed after all test methods in the current class have been run

· @BeforeTest: This will be executed before the first @Test annotated method. It can be executed multiple times before the test case.

· @AfterTest: A method with this annotation will be executed when all @Test annotated methods complete the execution of those classes inside the <test> tag in the TestNG.xml file.

· @BeforeSuite: It will run only once before all tests in the suite are executed.

· @AfterSuite: A method with this annotation will run once after the execution of all tests in the suite is complete.

· @BeforeGroups: This method will run before the first test run of that specific group.

· @AfterGroups: This method will run after all test methods of that group complete their execution.


Cucumber: If we are working on a behavior-driven development (BDD) project, we need to use Cucumber testing to help with communication and collaboration. Cucumber testing is a software testing process that deals with an application's behavior. It is used to test applications written in a BDD style. Cucumber tests are written in a simple, natural language that anyone can understand.

To use Cucumber testing for our project, we must set up a few things first.

1. Install the Cucumber command-line tool.

2. Create a file with a .feature extension. This file should contain a description of the feature you want to test and the individual scenarios you want to test.

3. Write your scenarios in Gherkin syntax. Each scenario should include the Given, When, and Then steps.

4. Run your tests using the Cucumber command-line tool.

Once you have created your .feature file, you can run your tests using the Cucumber command-line tool. This tool will parse your .feature file and execute your scenarios.

. feature file looks like this:

Feature: Sign up for an account

Scenario: Successful signup

Given I am on the signup page

When I fill out the form with my information

Then I should see a confirmation message

This .feature file contains a scenario that tests the signup feature. The system includes the Given, When, and Then steps that describe what should happen when the user tries to sign up for an account.

Once you have created your .feature file, you can run your tests using the Cucumber command-line tool. This tool will parse your .feature file and execute your scenarios.

Using Cucumber, we can test different types of tests:

Acceptance tests: These tests help you determine if an application meets the requirements the customer or client sets. Acceptance tests are typically written in Gherkin syntax.

Functional tests: These tests help you determine if an application is working as expected. Functional tests are typically written in a programming language like Ruby or JavaScript.

Unit tests: These tests help you determine if a specific unit of code is working as expected. Unit tests are typically written in a programming language like Ruby or JavaScript.

Integration tests: These tests help you determine if different parts of an application are working together as expected. Integration tests are typically written in a programming language like Ruby or JavaScript.

How to run Cucumber tests

Once you have written your Cucumber tests, you can run them using the Cucumber command-line tool. This tool will parse your .feature file and execute your scenarios.

The Cucumber command-line tool will generate a report showing your tests' results. The report will show which scenarios passed and which scenarios failed.

Feature: login to access the site as a user

Scenario: Successful Login

Given I am on the login page

When I fill in "username" with "LMS"

And I fill in the "password" with "lms"

And I click on the "Login" button

Then I should see the "Home page”

Scenario: Failed Login

Given I am on the login page

When I fill in "username" with "LMS"

And I fill in "password" with "wrong password"

And I click on the "Login" button

Then I should see the "Error message”


When we run we will get this result:


Two scenarios (1 passed, one failed)

Eight steps (4 passed, four failed)


In this report, you can see which scenarios passed and which scenarios failed. You can also see the steps that were executed for each scenario.

The report helps debug your Cucumber tests. It can also help you understand why a particular test might have failed.

Common problems with Cucumber testing and how to solve them:

There are a few common problems that can occur when writing Cucumber tests. Here are some tips to help you avoid these problems:

  • Make sure your scenarios are clear and concise. This will help ensure that your tests are easy to understand and maintain.

  • Use tags to organize and run specific scenarios. This will help you keep your Cucumber tests organized and ensure that only the scenarios you want to run are executed.

  • Use the background keywords to avoid duplication. This keyword can be used to define steps that should be run before each scenario in a feature file.

  • This can help avoid duplication and make your scenarios easier to read.

  • Ensure that your .feature files are located in the correct directory. Cucumber will look for .feature files in the directory where the Cucumber command is run.

  • Make sure that your .feature files are located in this directory, or you will not be able to run your tests.

Jenkins:

Jenkins is a very popular open-source CI/CD (continuous integration or continuous delivery) build tool, which provides numerous plugins for integration with multiple test automation tools and frameworks into the test pipeline. When it comes to Test Automation, Jenkins provides plugins that help run test suites, gather dashboard results, and provide details on failures.

Advantages:

· Summarizes the results: Most plugins also summarize the test results and display them as an HTML page.

  • Provides Trends: Jenkins keeps track of results and displays them as a trend graph. This offers a better view of how the tests have fared in the past.

  • Display details on Test Failures: Test results are tabulated, and failures are logged with the test results.

  • It can be integrated with any source management tool

  • It can be Integrated with Chat tools like Teams, and Slack for notifying the status of build jobs

  • Jenkins can be used to send emails with Test Execution Report


When we understand all these tools then we should work on creating a project structure. After creating the structure, it will look like that.



Report

After executed, we can get the report file


Hope you got the basic idea about Selenium Hybrid Framework. Thank you for reading.

497 views0 comments

Recent Posts

See All

Comentarios

Obtuvo 0 de 5 estrellas.
Aún no hay calificaciones

Agrega una calificación
bottom of page