.

Functional + UI Automation Framework using Selenium – Page Object Model



Introduction

We can design a framework that not only limit our automation usage to regression rather we may use it for functional and UI verification as well.

The most common things we test using our automation suites are Text, Presence of objects or attributes of objects. These do not ensure about UI of the application. We can create a repository of images (like objects) and ensure that images on test build are exactly matching with stable build.







Salient Features

-  Full page screenshot comparison ensures quick UI and smoke testing.

-  Object level image comparison allows UI verification for specific objects.

-  By injecting JavaScript we can exclude animated objects from being compared.

-  It can capture issue at pixel level which are sometimes hard to locate through naked eyes.

-  Can be used for web as well as native applications on iOS or android.







Setup Includes

Selenium Page Object Model based wrapper  

testNG framework 

ant / Maven 

Jenkins




Report




STEPS - How to Implement

1. Capture driver screenshot.

2. Get width & height  of the element.

3. Crop element screenshot from the complete screenshot using subImage function of bufferedImage

4. Keep copy of correct image in Image repository before running test.

5. Compare actual image with the one present in repository and calculate the % difference by reading & comparing pixels of both images.

6. If difference is greater than 2-5% then mark test case as failure.


  

1 comment :

  1. Hi, do you have a code snippet for this? Could you please share it..

    ReplyDelete

Recent Posts