Image CAPTCHA
Enter the characters shown in the image.

You are here

How to avoid using wait statements in your UFT Framework

1 post / 0 new
Jonathan
Jonathan's picture
How to avoid using wait statements in your UFT Framework

When we manually test a feature, we wait for the object to appear on screen before performing any action on it. Similarly, automated scripts wait for a certain pre-defined time before performing any action on the object

In the below code, you can see that we have a Const variable WAITFOR. This variable is used as a timer. The script will wait for a maximum of 10s for the object to be displayed.

Const WAITFOR = 10

Function objFound(object)

If object.exist(WAITFOR) Then

 objFound = True Else objFound = False

End If

End Function 

 

Pros:

Declare the constant in one file and access it throughout the framework.

Instead of using wait() and exist() functions all over the place, you can call objFound(object) and then perform the next action.

If objFound(Browser("name:=Google").Page("title:=Google").WebEdit("name:=q")) Then

Browser("name:=Google").Page("title:=Google").WebEdit("name:=q").Set "Isn't UFT an awesome Automation Tool?"

End If

 

Cons:

While the above solution works most of the time, there are instances where the application is a lot slower and the object takes more than 10s to load. 

In case of negative Test Cases, the script must wait for entire 10s and then return False. 

 

Solution:

For Positive Test Case

Use Do Loop Until the condition is true. Exist(0) will immediately return the Boolean value.

If objFound(Browser("name:=Google").Page("title:=Google").WebEdit("name:=q")) Then

Browser("name:=Google").Page("title:=Google").WebEdit("name:=q").Set "Is UFT an awesome Automation Tool?"

End If

Function objFound(object)

Do Loop Until object.exist(0)

objFound = True

End Function

 

For Negative Test Case

Use Do Loop While the condition is true. Exist(0) will immediately return the Boolean value.

If objNotFound(Browser("name:=Google").Page("title:=Google").WebEdit("name:=q")) Then

Msgbox "Object Not Found"

End If

Function objNotFound(object)

Do  Loop While object.exist(0)

objNotFound = True

End Function

Using the above two functions, we can make our script foolproof and independent of the performance of AUT.

 

By Raman Sivasankar Sr. QA Engineer at Pacific Life

Read more at Linkedin

Cool

MANUFACTURERS Wallboard

Testing tool manufacturers world-wide list
10Levels ABID CONSULTING AccelQ Accord Software ActiMind AdaCore
AdaLog AgileLoad AgileWay Agitar Algorismi ALL4TEC
Android Apache Apica Apollo Systems AppAssist.mobi Applitools
AppPerfect Appsee ApTest Assertible Assure Atlassian
AutoIt Consulti .. Automation Anyw .. Automation Cons .. Aztaz Software Backtrace I/O Badboy
BlazeMeter Borvid BrowserStack BSQUARE BStriker Intern .. CA Technologies
Canonical Canoo Catch Limited CelestialTeapot Celtic Testing .. Chris Mallett
Cleanscape ClicTest CloudQA CodeCentrix CodePlex projec .. Codoid
Cogitek Compuware Configure IT Conflair ConSol Core Services
Countersoft CresTech Softwa .. Cross Browser T .. Crosscheck Netw .. Crowdsourced Te .. Cucumber Ltd
Cyara Cygnet Infotech DareBoost Databene Datamatics Glob .. DevExpress
DTM soft Dynatrace LLC EasyQA Eclipse EKA TechServ Elvior
Emmanuel Jorge Empirix EPAM Systems Equafy Esterel Technol .. eXept Software ..
Experitest Finaris Froglogic FrontEndART Ltd GeneXus GitHub project
gnoso Google Code Pro .. GrammaTech Gurock Software Hewlett Packard .. Hexawise
High-Tech Bridg .. Hiptest Hitex IBM Rational imbus Shanghai Impetus
Inflectra informUp INTALIO InTENSO - IT Ex .. Ipswitch Jamo Solutions
Janova JAR Technologie .. JBoss Developer jClarity Jellly.io JetBrains
Jively jQuery foundati .. JS Foundation Jspresso Kanoah Software KMS Technology
Kualitee LDRA Limited Litmus LoadFocus Loadster Perfor .. MarathonITE
Marketcircle Marketcircle Maveryx Meliora Ltd Micro Focus Sof .. Microsoft
Mobile Labs Mobile1st Mockaroo, LLC ModalLogic IT Monkop Mozila
MSys Technologi .. Navicat NeoTys NetCart NORIZZK.COM Novosync Mobili ..
NRG Global NTT Resonant OC Systems Odin Technology OpCord Oracle
Orcanos Original Softwa .. Ossia Conseil OW2 PANAYA Parasoft
PassMark Patterson Consu .. Perfecto Mobile Pivotal, Inc. Plutora Postman (API To ..
PractiTest PrimaTest Process One Programming Res .. Psoda PureLoad
PushToTest Python Q-Assurance QA Systems QACube QASymphony
QAWorks QMetry Quali Qualitia Softwa .. Quality First S .. Quotium
RadView Softwar .. Ranorex RedLine13 Reflective Solu .. ReQtest RevDeBug
Robotium Tech Rogue Wave Soft .. Rommana Softwar .. RTTS ruby-doc.org Runscope
Sandklef GNU La .. Sauce Labs Seapine Softwar .. SeleniumHQ Sencha Sensiple
Siemens PLM Sof .. SmartBear Softw .. SmarteSoft SOASTA SoftLogica Softomotive
Softsmith Solution-Soft SonarSource Sourceforge SqashTeam SQS Software Qu ..
Square Stimulus Techno .. Swifting AB Synopsys T-komp T-Plan
TechExcel TechTalk Telerik By Prog .. Tellurium Test Collab Test Goat
Test Recon TestCaseLab testCloud.de Gm .. Testenium Testim.io Testing Technol ..
TestingBot TestLodge Testmunk TestObject GmbH Testomato TestOptimal
TestPlant TestPro Testuff The Core Bankin .. The MathWorks The Open Group
thePHP.cc Thoughtbot Thoughtworks Tigris.org Time Simulator Top-Q
Trace Technolog .. TrendIC TRICENTIS Tritusa Pty Ltd TWD Solutions P .. TypeMock
Tyto Software Ubertesters UniTESK Universal Test .. Usetrace Ltd Utrecht Univers ..
Validata Group Vanamco AG Vector Software Veracode Verifaya Corpor .. Verit
VersionOne Viewlike.us Vornex Inc. Watir.com WcfStorm Soluti .. We Are Mammoth
Web Performance .. Wintask Wireshark Found .. Worksoft Xceptance XebiaLabs
XK72 Xpand IT XQual ZAPTEST Zeenyx Software .. Zephyr
Zeta Software zutubi pty

Theme by Danetsoft and Danang Probo Sayekti