Saturday, March 28, 2020

Healenium - A self healing remedy to broken elements!

WHY


Whether you name it test automation or automation testing, the tool which has surpassed all the  others in this segment is Selenium. Selenium has certainly proved to be as the de-facto standard when it comes to automation testing.

On the other hand, software development methodology has also evolved over a period of time from the classic waterfall model to the agile practice.
Today, many of the software projects follow the scrum practice of the agile manifesto to leverage the advantages of quick feedback and change requests loop.
The change requests can majorly be categorized into two categories:
  • Functional
  • UI
UI change category is what poses a lot of hiccups in automation testing. Due to this fact, the scripts developed before might go wrong at the time of execution.
Moreover, it also incurs a lot of maintenance headache.

Today, there are many commercial tools available which have the sought feature of auto healing of elements. But, they all come with a cost too.
Healenium is the tool which I came across which not only focuses upon this very feature solely but at the same time it is free to use.

WHAT


A brief introduction about Healenium:
It is a Java based project focuses upon Self healing act for Selenium based tests developed by the Anna Chernyshova team, sponsored by Epam.

As the name implies, it has a deep AI sense to do the healing tricks with respect to elemental changes at run time.
It also features a plugin for IntelliJ IDEA to update the new values of controls in the code base with just one click.
It also supports many advanced features like:
  • Parallel test run
  • Remote test run 
  • Iframes 
  • Actions 
  • Selenide integration

HOW

Before we see Healenium in action let us decide the platter.

The platter will consist of,
Let us see the Healenium in action.

Project Structure



Implementation of Healenium basics in the project:
  • Add the Healenium dependency:


  • To verify, see under the External Libraries section of the project:

  • Add the healenium.properties file:

    • recovery-tries - list of proposed healed locators
    • basePath - folder to store base locators path                 
    • reportPath - folder to save test report with healing information
    • screenshotPath - folder to save screenshots of healed elements
    • heal-enabled - you could enable or disable healing by setting true or false flag to this variable
    • *Important! Do not delete data from the folder where files with new   locators are stored. They are used to perform self-healing in next automation runs

  • Implement SelfHealingDriver:


The Test Method flows like this:

   Launch the application on the given URL and Click on Desktop option from the navigation menu


   Click on Mac option under Desktop


   Click on iMac and then on Add to Cart option


   Click on Cart


   Click on View Cart


   Verify the item added to the cart



We are going to see two fundamental scenarios here:
  • Element locator change
  • Element position change

The element under scrutiny "Add to Cart":
  • HTML Section


  • POM Section

  • Test Method Section


1. Element locator change
  • Element ID Locator Changed from 
    • "button-cart" to "button-cart1"


  • In anticipation of element's locator change - without Healenium
    • heal-enabled=false

    • Script failed
  • In anticipation of element's locator change - with Healenium
    • heal-enabled=true

    • Script succeeded

2. Element position change
  • Element position changed with inclusion of an additional 
    • "<div>" inside  "<div class="form-group">"

  • In anticipation of element's position change - without Healenium
    • heal-enabled=false
    • Script failed
  • In anticipation of element's position change - with Healenium
    • heal-enabled=true
    • Script succeeded

BEHIND THE SCENE


  • Extracts the entire html page by page and saves it in the form of  json in the name of SHA Code
  • For any element change, uses that extracted json file to get the new element using its deep AI senses
  • Takes the screenshot of the changed element with red highlights around

  • Creates a data.json file consisting of healing information

HEALENIUM FOLDER STRUCTURES


  • Build

  • SHA

  • Screenshots

  • Reports




Important links

https://github.com/healenium/healenium-web/wiki
https://github.com/healenium/healenium-example
https://github.com/healenium/healenium-web


Courtesy

This blog is published by courtesy of Anna Chernyshova and the team in the interest of new innovation and learning.



1 comment:

Blog head

Healenium - A self healing remedy to broken elements!