Showing posts with label Automation Frameworks. Show all posts
Showing posts with label Automation Frameworks. Show all posts

Friday, August 26, 2022

Drivers for tool selection

 Drivers for tool selection

1.lower opex

2. Faster payback/break even

3. Faster script build

4. Faster script run -execution and maintenance 

5. Most technology supported

6. Better % automation

7. Easier to skill

8. Faster to scale

9. Easier end to end automation

10. No manual script creation

11. Industrialisation of testing




Sunday, July 17, 2022

Test Automation Framework

 Framework

A framework defines a set of rules or best practices which we can follow in a systematic way to achieve the desired results

 

popular Test Automation Frameworks

  • Modular Testing Framework
  • Data Driven Testing Framework
  • Keyword Driven Testing Framework
  • Hybrid Testing Framework
  • Behavior Driven Development Framework

Why Framework

In a test automation project, we do perform different tasks by using different types of files. To organize and manage all the files and to finish all the tasks in a systematic approach we use a framework.

 advantages of using Test Automation Framework

  1. Saves time and money. Automation testing is faster in execution
  2. Reusability of code. Create one time and execute multiple times with less or no maintenance
  3. Easy reporting. It generates automatic reports after test execution
  4. Easy for compatibility testing. It enables parallel execution in combination of different OS and browser environments
  5. Low cost maintenance. It is cheaper compared to manual testing in a long run
  6. Automated testing is more reliable
  7. Automated testing is more powerful and versatile
  8. It is mostly used for regression testing. Supports execution of repeated test cases
  9. Minimal manual intervention. Test scripts can be run unattended
  10. Maximum coverage. It helps to increase the test coverage

 

Monday, March 29, 2021

POSTMAN-NewMan CLI API Automation

 INTRODUCTION

This article outlines automation of APIs using postman and new line command line interface as well as batch setup. The paper proposes a way to create collections in postman, use those collection in new man for automation testing and reporting the automation results in different formats.

Overview

Scope of testing will be API testing for this whitepaper. Postman-Newman CLI provides a command line interface for API automation to run quick API automation test

Use of Postman

• Testing rest services using POSTMAN

·         Workspace: stores all collections

·         Collections: collections of requests

·         Test suits : contains tests or test cases

• HTTP request Methods

·         Create a record- POST

·         Retrieve/verify data – GET

·         Update data – PUT

·         Delete data – DELETE

• URL : domain + URI (also call as endpoints)

API Architecture

API calls Collection include mainly three things:

• HTTP headers

• HTTP Request (POST, GET, PUT, DELETE )

• Status Code/ Response Code

·         Date

·         Version

·         Description

·         Author

Newman

Newman is a command line Collection Runner for Postman. It allows you to run and test a Postman Collection directly from the command line. It is built with extensibility in mind so that you can easily integrate it with your continuous integration servers and build systems.

Newman maintains feature parity with Postman and allows you to run collections the way they are executed inside the collection runner in Postman.

Newman resides in the NPM registry and on GitHub.

Pre-requisites

➢ Installation can be done in two ways o Install as google plug in

·         Download as application

o   Download and install node js using below link Link: https://nodejs.org/en/download/

o   Install newman cli globally: npm install -g newman

o To check the version of npm : Npm -v

o To check the version of newman : Newman -v

➢ To get HTML reports in postman ,downloa using the cmd : install -g newman-reporter-htmlextra

Usage

➢ After installing, you can create request collections in postman and run the collection through postman

To share the collections through postman with other test members use below Share collection option.

 To export the collection use the Export button. Once you export the collection, use this collection to run through newman

 API Automation Framework in Postman-Newman CLI

API automation framework can we implement using following way.

A.      Define phase

·         In define phase- we need to create different test collection based on the test

·         requirement and set of data and environments

B.      Execute Phase

·         Once the collections are defined we need to export them and get check in the repositories using github or bitbucket

·         Write the batch job using command line interface for Newman commands to run the collection and generate the report formats

C.      Automate phase

·         In Jenkin, we need to create new item with freestyle project

·         Add build step with “Execute Shell” shell command

·         Assign the newman command or batch job in Jenkin project to get the continuous

·         integration

·         Click save

Run from command line with environment specific collection

➢ Basic setup

--folder [folderName] Specify a single folder to run from a collection.

-e, --environment [file|URL] Specify a Postman environment as a JSON [file] -d, --iteration-data [file] Specify a data file to use either json or csv

-g, --globals [file] Specify a Postman global file as JSON [file]

-n, --iteration-count [number] Define the number of iterations to run

➢ Request options

--delay-request [number] Specify a delay (in ms) between requests [number] --timeout-request [number] Specify a request timeout (in ms) for a request

➢ Misc.

--bail Stops the runner when a test case fails

--silent Disable terminal output

--color off Disable colored output (auto

-k, --insecure Disable strict ssl

-x, --suppress-exit-code Continue running tests even after a failure, but exit with code=0 --ignore-redirectsDisable automatic following of 3XX responses

--verbose Show detailed information of collection run and each request sent

Use the -n option to set the number of iterations to run the collection. Steps to run the collection

o Go to command line with folder in which you kept the postman collection To run the test collection through Newman command line

  ➢ You can run collection on specific environment with below command newman run [collection_filename.son] -e [environment_filename. json]

➢ Path of newman in system : C:\Users\[User Name]\newman

Save Results

Results can be saved as JSON data, HTML report, excel report, command line report, junit report and multiple format together as well. By passing a filepath to command you indicate where the file should be generated. If no filename is passed, a default will be used.

c:\Users\[user dir]\Desktop\Postman Files>newman run "example collection1.postman_collection.json" - d data.csv -r htmlextra

 -e is the flag for Environment. This should run through your entire Collection of end.

html report

Newman run “collection name.json” -e “environment.json” -r htmlextra

Junit report

Newman run “collection name.json” -e “environment.json” -r junit

excel report

Newman run “collection name.json” -e “environment.json” -r csv

Command line report

Newman run “collection name.json” -e “environment.json” -r cli

json report

Newman run “collection name.json” -e “environment.json” -r json

Multiple format report

Newman run “collection name.json” -e “environment.json” -r csv,htmlextra,junit

To export report to any location

Newman run “collection name.json” -e “environment.json” -r json -export “newpath” Result:

BDD Cucumber -resequencing the feature file and scenarios

 Hey Folks,

There may be a situation while you need to call your scenario outline of one feature needs to call in particular sequence based on application flow, this can be achieved by adding the tags to scenario outline with priority will work.

However, what happens when you need to sequence your scenario outline with different feature files? 

By default, BDD cucumber takes feature names alphabetically during the execution and then based on your tag sequences. So, if you want to resequencing your scenario in different features file, then you need to give your feature names in sequence of alphabet or append some numbering. if it still doesn't work then rename the feature file name itself and it will work. for example,

Feature file name : 01Feature1.feature, 02Feature2.feature

Feature Name: 01Feature1, 02 Feature2

Cheers,

TJ


Tuesday, October 20, 2020

Steps to implement Allure Reporting in Selenium java

 Hey Guys,

Steps to implement Allure reporting in selenium java framework.

Allure is an open-source framework designed to create interactive and comprehensive test report.

Each time when we run automation tests, we will have test results to view details about no. of tests passed, failed and failure details etc. And few reports also include test failure screenshots.

Allure report works

When we run our tests, every popular test framework generates junit-style xml report which will be used by Allure to generate HTML report. Allure reports has provided adapters for Java, PHP, Ruby, Python, Scala and C# test frameworks.

Steps to Generate Allure Reports

Install and configuration

  • Install Allure report command line application
  • do this manually by downloading the latest version as a zip archive from bintray.
    • Unpack the archive to allure-command line directory
    • Navigate to bin directory
    • Add allure to system PATH.

Implementation in code

  •            Create Maven project
  •             Add allure maven dependencies in pom.xml file and also add  AspectJ Weaver dependency along with allure.
  •             Create two test file in src/test/java folder and append the allure features in it for writing reports
  •             Create Testng.xml file
  •             We can add environment details in allure report by adding following
      •   Environment.properties
      •   Environment.xml
  •              We can categories the failed cases/defects using categories.json file
  • append the features of allure report to code like @step, @feature etc

 Run the code and generate the allure report

  •  Go to command prompt and in project directory and run the command
    • Mvn clean test
  • Or run the code through eclipse/intelij
  • Go to command prompt and generate the allure report in temporary folder using command
    • Allure serve <path of allure report>  (Generate report in temporary folder)
    • Allure generate <path of allure report> (Generate report in c:/user directory with allure folder)
    • Allure open <path of allure report>
    • Allure generate <path of allure report> --clean (will overwrite the existing report)

You can find more information on Allure documentation.

 Cheers.

TJ

Wednesday, September 16, 2020

Rest Assured Automation - API

Hello All,

 

Try to put some information around Rest Assured API testing using eClipse, TestNG. in subsequent blog, will provide some technical view.

 

API testing using RestAssured

  • RestAssured itself is API designed for automating Rest services/ Rest APIs.
  • Implemented using java classes
  • Available in jar files
  • Multiple request, get response from apis, validate data etc
  • Restassured only support Rest services, it not support SOAP services 

Setting up

  • Java
  • Eclipse
  • Test NG
  • Maven (specify dependencies)  

Steps:

  1. Create Maven project in eclipse
  2. Need to update POM.xml file
    1. RestAssured (https://mvnrepository.com/artifact/io.rest-assured/rest-assured/4.3.1)
    2. TestNG (https://mvnrepository.com/artifact/org.testng/testng/7.3.0)
    3. JSON – simple (https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple/1.1.1)
    4. Apache poi (https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml/4.1.2, https://mvnrepository.com/artifact/org.apache.poi/poi/4.1.2)

 

Validations:

Status Code

Status Line

Request body n parameters

Success code

Validate Header

Json contains

Print headers

 

Data driven testing

1 prepare test data in excel

2 add apache poi dependency in pom.xml  or download apache poi & attach jars to your build path

3 XL utility file(java class file) which will read data from excel

4 write TestNG with data provider method

Cheers,

TJ 

 


Wednesday, December 19, 2018

Test Complete /UFT- Automation of Database

dim objconnection
set objconnection= Createobject("Adodb. co nection)

'function to connect sql server
public function opendbconnection()
aqutils. delay 3000
strcoonectionstring="provoder=sqloledb;datasourcee=strdatasourceval;initial catalog=strcatval;security=sspi;persist security info=true"
objconnection. open strcoonectionstring
if objconnection. state=1  then
   log. message "DB connect"
else
Log. message "Db not connect"
end if
end function

'function to close db connection
public function closedbconnection()
objconnection. close
if objconnection. state <>1  then
   log. message "DB connection close"
else
Log. message "Db not connection not close"
end if

end function

dim strcodedelimiter, strDBrowdelimiter
strdbrowdelimiter="@@"
strcodedelimiter="|"

public function get_db_row()

dim objrecordset, strdbrow
strdbrow=""
if objconnection. state=1 then
    set objrecordset =createobject (adodb. recordset")
    objrecordset. activeconnection=objconnection
   objrecordset. open DBquery, objconnection
   if not objrecordset. eof then
    while not objrecordset. eof
         for intdbcolcounter=0 to objrecordset. fields. count-1  step 1
               strcurrentvalue=objrecordset. fields(intdbcolcounter). value
          if isnull(strcurrentvalue) or strcurrentvalue ="" then
           strcurrentvalue =Null
          end if
strdbrow=strdbrow & strcodedelimiter & strcurrentvalue
next
strdbrow= strdbrow & strdbroedelimiter
objrecordset. movenext
wend
if left(strdbrow, 1)=strcodedelimiter then
    strdbrow =right(strdbrow, len(strdbrow) - 1)
end if
strdbrow =replace(strdbrow, strdbrowdelimiter & strcodedelimiter, strrowdelimiter)
objrecordset. close
set objrecordset =nothing

else
    log. message "no data found"
end if
get_db_row= strdbrow

else
     log. message "db connection fail"
end if

end function

'function to update db row
public function uodate_db_row()
dim objrecordset, strdbrow
strdbrow=""
if objconnection. state=1 then
    set objrecordset =createobject (adodb. recordset")
    objrecordset. activeconnection=objconnection
   objrecordset. open DBquery, objconnection
   if err. description <>"" then
          log. message "no data found in db"
    else
bdbflag=true
end if
else
bdbflag=false
log. message "db connection failed"
end if
update_db_row=bdbflag

end function

'function to compare db value
public function comparedbvalue(strvalidatiinval, strdbvalue)
dim bdbvalflag
if aqutils. vartostr (strvalidatiinval) =aqutils. vartostr (strdbvalue) then
   bdbvalflag=true
else
bdbvalflag=false
end if
comparedbvalue=bdbvalflag
end function

Test Complete / UFT-Run functions dynemic through excel files

Hey folks,

sometimes functions execution flow needs to controll through excel files and need to run the functions dynemic, so hope this line of code will help. Same applies to UFT as well.

in excel sheet, for exampme TC1 having FUNC1-10 then,

for fncnt=1 to sheet. columncount
    strfunctionname=""
    if(aqconvert. vartostr(fncnt)) <>"" then
         strfunctionname=aqconvert. vartostr(testcasedriver. value(fncnt))
        functiontorun="Call" & strfunctionname
       execute functiontorun
    end if
next

wishes,
Trupti

Friday, October 5, 2018

Read XML file as string using Vbscript

hi folks, To read XML file as entirely string we can use below logic. Hope it will useful.

set xmldoc=createobject("MICROSOFT. XMLDOM")
xmldoc. async=false
xmldoc. load(recentxmlfilepath)
for each ochdnd in xmldoc. documentelement. childnodes
     strxmldocline=ochdnd. nodename & ":" & ochdnd. text & vbcrlf
xmldocdata= xmldocdata & strxmldocline
next
msgbox xmldocdata

cheers
Trupti

Tuesday, October 31, 2017

Key design activities and component for framework

Folks,

Following are key design activities for create robust automation framework

1. Define standard project folder hierarchy
2. Define standard configuration and launcher script.
3. Design standard format for automation component
4. Define reusable modules to reduce development and maintenance cost
5. Define layered architecture of reusable modules
6. Design standard flow control module
7. Design standard data storage, loading, sharing mechanism
8. Define standard reporting mechanism
9. Design standard error or exception handling mechanism

Components
1. Controller
2. Reusable component
3. Event Handler
4. Reporter

Regards, Trupti 

Monday, October 30, 2017

Batch Process Application testing using UFT

Greetings to Readers,

Another try on sharing knowledge for batch process application testing using UFT. Below are few approach for automation framework in batch process applications.


  1. Understand the all batch process applications- sub batches functions, based on it decide the automation scenarios. sequence of batches for run, input and output for that batch, validation rules, where that batch files are deployed or run, how to run, how can we run using UFT etc needs to take care
  2. At a time, how many batches can run, do they require same inputs or outputs, dependent on each other, validation for some files, inputs etc.
  3. Try to use different library for all sub batch files, as maintenance is less
  4. Try to use generic functions for some validations of common batches validations
  5. Try to use global variables for maintain data through the batches for validations
  6. Use hybrid framework for automation with combination of module function based approach. here data will not be vary mostly for such type of applications.
Regards,
Trupti

Pega Automation approach using UFT

Hey folks,

I try here to give you reference for taking automation approach for PEGA automation projects. I have used UFT 12.02 for PEGA 7.2.2 version automation in one of my project. Following are checklist, which can help.

  1. As PEGA application is rule based and flow based application, there were always few set of pages will be used in application. Before deciding framework, dry run the whole application flow for the pages behavior.
  2. As pages, might be limited, we can use object repository approach for the application as size will not grow. For few PEGAcontrols, we need to write descriptive programming as well. Mostly frame related problems occurs for few control identification.
  3. As it is rule based application, may be require to run different set of test with combination of test data to test the rules, but pages remains same. So try use data driven approach while using framework. Keep all the functions generic so with any combination of test data, we can use same functions.
  4. As its having flow based application too, driver script should having provision to calling different functions in sequences to drive the flow. Write module based functions for easy flow driven. 
  5. Most of the flow driven by some actions like approve, reject etc., so write function in generic with switch cases to handle the different flow along with data passing approach.
  6. Few scenarios may be having multiple data at same flow, then there should be some provision to handle multiple entry of test data by passing argument in split way.
  7. Few controls are dynamic based on the conditions, so we can handle it using regular expression. for ex., few property values like , \strname1 can handle in as $\strname1, like that. 
  8. Controls are similar to rest web applications for PEGA. UFT can identify it properly, there is no additional add ins require.
  9. For error handling, we can used on error resume next statement at function level.
  10. Facing sync issue for application, which hurdle in night run execution. so increase wait time much to avoid such things.
  11. Try to keep all function libary at module levels.
  12. Use environment variables for sharing constant value across test suite
  13. keep configuration files for easy project path references.
  14. keep files references at top level with public variable to access across the test suite for implementing rules.
  15. keep generic functions to connect external files, fetching values or rules to implement, export test results etc.
  16. while executing UFT , we need to enable add on in internet explore for PEGA.
Regards,
Trupti

Thursday, October 26, 2017

PEGA Application Testing

Hi folks,

After long time, publish another article on Pega Application testing.

Pega application testing needs to take different approach of testing then normal STLC. Pega applications are rule based application having more than 10 k rules. I was worked with pega version 7.2.2.

Pegasystems is a leading BPM / Case Management platform provider. As leaders they are at the forefront in offering automated testing capabilities in the BPM space. Testing Pega BPM based applications from the UI is still a challenge however. Pega testing is followed in agile model. Pega is fast growing tool which makes millions of users happy. It is a business process management (BPM) tool which was founded by Alen Trefler. Pega PRPC is an Application Development Product from Pega Systems. To Test Pega Applications one need to know the Testing Management Framework (TMF) from Pega as well as Required knowledge in Manual Testing and Regressive Testing. Using Pega Unit Testing Feature one can test the Flow Rules, Decision Rules, Integrations and Automated Regression Testing. With the help of pega testing we test the pega applications very wisely and deliver as a defect free.It uses concept called PRPC which is a pega rules and process commander. It uses Rules set to design the pega applications.

As it is rule based application with large set of rules, automation tester needs to create their own framework for rule implementation. use unit testing or functional approach is more better to reusability purpose. Rules can be implemented as functional validations and we can add modules or component base approach as well for the flow of application.

As per research, selenium is best tool for pega testing, but I have used UFT 12.02 for the pega automation. Later on, project move in selenium, but I didn't find much difference in both apart from licence cost of UFT. all technical problem still resides in selenium too, which was happen with UFT.

(Reference taken from quora for below content)
Pega has different Debugging Tool inbuilt to test the Application .we have different types of testing in pega .
Types of Testing :
  • Flow based Testing – Concentrates on Business flows (E2E), involving multiple roles and interfaces
  • Role based Testing – Testing based on workgroups – Skills, UI etc
  • Rule based Testing –
    1. Business Rules - Formulae, delegated rules etc
    2. Technical Rules - integration rules etc
Pega Debugging Tools:
  • Clipboard
  • Tracer
  • Rule Inspector/UI Inspector
  • PLA (PegaRULES Log Analyzer)
  • PAL (Performance Analyzer)
  • AUT (Automated Unit Testing)
(Reference over)

For automation perspective- we should go with hybrid -data driven framework with modular approach, which work best for rule implementation with different set of data to all modules.

Few challenges in Pega projects like-
1. control identification for web edits not work proper- down key or keystroke approach needs to write for most of controls
2.Nightly run not work- application sync issues occurs much
3. modules approach required and for that application knowledge must be with you to take the decision for create modules-passing parameters, use parameters etc.
4. due to rule based implementation execution time takes more for end to end flows.
5. keep provision for normal end to end flow execution, rule base validation for module execution, role base validation etc in script itself.

Regards,
Trupti