barclays core prime brokerage qa automated gui testing

61
Barclays Core Prime Brokerage QA Automated GUI Testing Migration Analysis Project # KMS 1603 A Major Qualifying Project Report Submitted to the faculty of Worcester Polytechnic Institute In partial fulfillment of the requirements of the Degree of Bachelor of Science Submitted on 17th December 2016 In Cooperation with: Barclays PLC Submitted by: Didi Dai, Industrial Engineering and Management Information System Jonathan Ho Wu, Electrical and Computer Engineering Submitted to: On-site Liaison: Michael Irving Bharat Rao Karlene Wright Project Advisors: Professor Michael J. Ciaraldi, Department of Computer Science Professor Xinming Huang, Department of Electrical and Computer Engineering Professor Renata Konrad, Foisie School of Business Professor Kevin M. Sweeney, Foisie School of Business

Upload: others

Post on 03-Apr-2022

5 views

Category:

Documents


0 download

TRANSCRIPT

BarclaysCorePrimeBrokerageQAAutomatedGUITestingMigrationAnalysis

Project#KMS1603AMajorQualifyingProjectReport

SubmittedtothefacultyofWorcesterPolytechnicInstitute

InpartialfulfillmentoftherequirementsoftheDegreeofBachelorofScience

Submittedon17thDecember2016InCooperationwith:

BarclaysPLCSubmittedby:

DidiDai,IndustrialEngineeringandManagementInformationSystemJonathanHoWu,ElectricalandComputerEngineering

Submittedto:

On-siteLiaison:MichaelIrvingBharatRao

KarleneWright

ProjectAdvisors:ProfessorMichaelJ.Ciaraldi,DepartmentofComputerScience

ProfessorXinmingHuang,DepartmentofElectricalandComputerEngineeringProfessorRenataKonrad,FoisieSchoolofBusiness

ProfessorKevinM.Sweeney,FoisieSchoolofBusiness

i|Dai,HoWu

Abstract

Sponsored by the Core Prime Brokerage (PB) Quality Assurance team within the

InvestmentBankdivisionofBarclaysPLC,thisMajorQualifyingProject(MQP)reportcenteredon

webapplications.Thegoaloftheprojectwastofirstidentifyfree,open-sourcetoolsthatwould

serve as alternatives to the current Hewlett-Packard’s Quick Test Professional (QTP)/Unified

FunctionalTesting(UFT)solution,whilepreservingtheexistingcorefunctionswritteninVBScript

scripting language. After performing thorough exploratory analysis and research, the MQP

project team identified Selenium WebDriver as the best tool for Barclays Core PB's GUI

automation testing purposes. Our recommendations not only aim to help eliminate theUFT

licensecontentionandexecutionissues,butalsoaimtosavetheannuallicensingcostspentby

the Barclays Core PB team and reduce the time spent troubleshooting any GUI automation

testingissues.

ii|Dai,HoWu

Acknowledgments

ThesuccessofourMajorQualifyingProject(MQP)wouldnothavebeenpossiblewithout

thehelpofmanyindividualsinsideandoutsideofBarclays.Wewouldliketostartoffbythanking

BarclaysPLCforsponsoringusandenablingustohavethisinvaluableexperience.Inthisregard,

wewouldliketoespeciallythankourdirectbossandmentor,KarleneWright,forherexhaustive

support,guidance,andtechnologicalexpertisethroughoutourtenureatBarclays.Heroversight

anddedicationwerekeytothecompletionandsuccessofthisproject.Additionally,wewould

liketothankourotherbosses,MichaelIrvingandBharatRao,fortheirsupportandformaking

thisprojectapossibility.Furthermore,wewouldalsoliketoexpressourgratitudetowardsour

other teammembers in Kiev,Ukraine,whohelped us understand the entire automatedGUI

testingprocessmorethoroughly.

Wewouldalso liketothankourschool,WorcesterPolytechnic Institute(WPI)andthe

WPI Interdisciplinary and Global Studies Division (IGSD) for all their logistical support and

planning. Finally, we would like to thank our advisors, Professor Kevin Sweeney, Professor

MichaelCiaraldi,ProfessorXinmingHuang,andProfessorRenataKonradforalltheircontinuous

supportandguidancethroughouttheproject.

The project would not have reached this point if it was not for their countless

recommendationsandguidanceinsolidifyingourproject.Weareveryproudtohaveformpart

oftheWallStreetProjectCenterandtohaveworkedinsuchwithsuchanamazingandtalented

groupofpeoplewithinarenownedmultinationalcorporationsuchasBarclays.

iii|Dai,HoWu

Authorship

Content PrimaryAuthorTitlePage DidiDai

Abstract

Acknowledgments

AuthorshipJonathanHoWu

ExecutiveSummary DidiDaiChapter1:Introduction DidiDaiChapter2:Background JonathanHoWuChapter3:Methodology DidiDai

Chapter4:TwoFeasibleAutomationTools JonathanHoWuChapter5:RecommendationsandConclusions DidiDai,JonathanHoWu

Chapter6:Reflection DidiDai,JonathanHoWuWorksCited DidiDai,JonathanHoWuAppendix JonathanHoWu

Allsectionswereeditedasateam,withequalcontributionsmadebyeverymember.

iv|Dai,HoWu

ExecutiveSummary

Barclays,apioneer intheFin-Tech industry,drivestechnology implementationsacross

thecoreprimebrokerageintheUnitedStatesandtherestoftheworld.ThisMQPprojectworked

with the Core Prime Brokerage team in the IT department of Barclays America. Routinely,

BarclaysITdepartmentreleasesnewandupdatedwebappstotheircustomers.Beforereleasing

theapps,thequalityassuranceteamplaysanimportantroleintestingandinspectingtheapps.

However,thecurrenttestingsoftwarepresentsabigfinancialinvestmentforBarclaysandfaces

licensingissues.

Themain goal of thisMQP projectwas to identify for a no-cost replacement for the

current testing software, Hewlett-Packard’s Quick Test Professional (QTP)/Unified Functional

Testing(UFT).Tomakethenewtoolapplicableinthiscomplexenvironment,thereplacement

neededtosatisfythreeconstraints:(i)open-source;(ii)VBScriptscriptinglanguagesupport,and

(iii)GUIWebApplicationTestingSupport.TheMQPteamresearchedpossiblealternativesinthe

market. By identifying the strengths and weakness of each alternative, we conducted a

comparisonanalysistosupportourrecommendations. IdentifyingSeleniumWebDriverasthe

toolwhichbestsatisfiesBarclaysoperatingconstraints,weresearchedhowtoembedthenew

tool into Barclays’ automation GUI Web application testing framework and began the

implementation.Indoingso,BarclaysaddressestheexistingQTPlicensesissuesandsignificantly

reducesitsinvestmentintestingsoftware.TheMQPteamidentifiedamethodtogettheobject

fromthewebsitebyusingJAVAand linkingJAVAwithVBScript. Indoingso,existingVBScript

testing cases can be preserved and the automation testingmigration fromQTP to Selenium

WebDrivercanberealized.Foreasingtheprocessofgettinganobject,wealsoresearchedon

v|Dai,HoWu

theobjectrepositoryandfoundthreewaystostoreobjects,intheconditionofusingSelenium

WebDriver.

In addition, by learning the VBScript scripting language, we found the in-house

developmenttoolcouldalsobeareplacementofQTP.Thein-housedevelopmenttoolisgoing

tobedevelopedbyusingMicrosoftInternetExplorerObject.Thistoolcanbeaccomplishedby

writing VBScript scripting language only. Tool implementation and object storage were also

investigated.

Werecommendintheshortrun,BarclaysshoulduseInternetExploreObjecttocreate

the in-house development tool, as it is simpler andmore consistent since it uses a scripting

language that the employees are already familiar with. In the long run, we recommend

implementingSeleniumWebDriver,as it iseasiertodebugandit iscurrently indraftformto

becomeaW3C(WorldWideWebConsortium)WebStandard.

vi|Dai,HoWu

TableofContents

Abstract..................................................................................................................................i

Acknowledgments...................................................................................................................ii

Authorship.............................................................................................................................iii

ExecutiveSummary................................................................................................................iv

TableofFigures....................................................................................................................viii

ListofTables........................................................................................................................viii

Chapter1:Introduction..........................................................................................................1

Chapter2:Background...........................................................................................................22.1CurrentGUIWebApplicationAutomationTestingFramework....................................................3

2.1.1QualityCenter..............................................................................................................................32.1.2QTP/UFT......................................................................................................................................42.1.3VBScriptScriptingLanguage........................................................................................................52.1.4ORTranslator..............................................................................................................................52.1.5QTPObjectRepository.................................................................................................................5

2.2ProblemStatement.....................................................................................................................7

Chapter3:Methodology.........................................................................................................93.1ImplementationCriteria..............................................................................................................93.2ComparingExistingAutomationTools.........................................................................................93.3RationaleforEliminatingAlternatives.......................................................................................12

3.3.1MicrosoftCodedUITest............................................................................................................123.3.2TestComplete............................................................................................................................133.3.3RationalFunctional....................................................................................................................133.3.4iMacros......................................................................................................................................133.3.5OracleApplicationTestingSuite................................................................................................133.3.6EggplantFunctional...................................................................................................................133.3.7Sahi............................................................................................................................................143.3.8Maveryx.....................................................................................................................................14

Chapter4:TwoFeasibleAutomationTools............................................................................154.1Alternative#1:SeleniumWebDriver.........................................................................................15

4.1.1Background...............................................................................................................................154.1.2BrowserCompatibility...............................................................................................................164.1.3CallingJavabyUsingVBScript...................................................................................................174.1.4InstantiatingaSpecificBrowser................................................................................................184.1.5OtherWaystoGettheElementsbyUsingSelenium.................................................................184.1.6HowtoImplementanObjectRepositoryinSelenium?.............................................................19

4.2Alternative#2:UsingInternetExplorerObject..........................................................................26

vii|Dai,HoWu

4.2.1Background...............................................................................................................................264.2.2HowDoesItWork?....................................................................................................................264.2.3HowtoImplementtheObjectRepositoryintheIn-houseDevelopmentTool?.........................27

4.3ComparingtheTwoFeasibleSolutions......................................................................................294.3.1SeleniumWebDriver..................................................................................................................294.3.2InternetExplorerObject............................................................................................................30

Chapter5:RecommendationsandConclusions.....................................................................325.1Conclusion................................................................................................................................325.2Recommendations....................................................................................................................33

Chapter6:ReflectingonourExperienceatBarclays..............................................................356.1DiscussionofDesignintheContextoftheProject.....................................................................356.2DiscussionofConstraintsConsideredintheDesign...................................................................356.3DiscussionoftheNeedforLife-longLearning............................................................................36

WorksCited...........................................................................................................................37

Appendix1............................................................................................................................39

Appendix2............................................................................................................................40

Appendix3............................................................................................................................41

Appendix4............................................................................................................................43

Appendix5............................................................................................................................44

Appendix6............................................................................................................................45

Appendix7............................................................................................................................48

Appendix8............................................................................................................................50

Appendix9............................................................................................................................52

viii|Dai,HoWu

TableofFiguresFIGURE1:CURRENTGUITESTINGFRAMEWORKWORKFLOW...................................................................................3FIGURE2:QUALITYCENTER.........................................................................................................................................4FIGURE3:UFT/QTP.......................................................................................................................................................5FIGURE4:WEIGHTBARCHARTFORTHEAVAILABLEAUTOMATIONTESTINGTOOLS.............................................12FIGURE5:SELENIUMWEBDRIVERWORKINGPRINCIPLE..........................................................................................16FIGURE6:SAMPLEPROPERTYFILE............................................................................................................................22FIGURE7:OBJECTMAP..............................................................................................................................................23FIGURE8:THEPRINCIPLEOFTHEPAGEOBJECTMODEL...........................................................................................24FIGURE9:EXAMPLEOFAPAGEOBJECTMODELINACTION.....................................................................................25FIGURE10:CHILDELEMENTSINTHEPRODUCT........................................................................................................26FIGURE11:OBJECTREPOSITORYMANAGER.............................................................................................................28FIGURE12:EXPORTINGTHEXMLFILE.......................................................................................................................28

ListofTablesTABLE1:POTENTIALSOFTWARECOMPARISONTABLE............................................................................................10TABLE2:BESTOPTIONAMONGALLSOFTWARETOOLS...........................................................................................11

1|Dai,HoWu

Chapter1:Introduction

Our goal is to help develop an alternate solution that would allow the Core Prime

BrokerageQualityAssuranceteamtoruntheirexistingGUIautomatedtestswithoutusingHP

Enterprise’sUnifiedFunctionalTesting(UFT)softwaretoo.

We first reviewed the current Quality Assurance framework and then identified two

solutionscapableofreplacingtheUFT’sexecutionpieceofcode,whilemaintainingtheexisting

corefunctionswritteninVBScriptscriptinglanguage.

By the end of our project, we provided Barclays with a deliverable that detailed the

recommendationsonwhichtoolisthemosteffectiveandhowtostartimplementingthemost

suitable toolwhile considering the future testingofBarclaysCorePrimeBrokerageGUIWeb

applications.

2|Dai,HoWu

Chapter2:Background

Barclays Bank PLC, founded in 1690, is one of the largest multinational banking and

financialservicescompaniesintheUnitedKingdom,anditsheadquarterisinLondon(Delaware,

2016). Barclays provides different financial services in retail, wholesale, investment banking,

wealthmanagement,mortgagelendingandcreditcards,whichalloperateinmultiplecountries

acrossEurope,theAmericas,Asia,andAfrica.TherearefourcorebusinesssectorsofBarclays:

Personal & Corporate (Personal Banking, Corporate Banking, Wealth & Investment

Management),Barclaycard,InvestmentBankingandAfrica.Barclayshasaprimarylistingonthe

LondonStockExchangeandasecondarylistingontheNewYorkStockExchange.Attheendof

2011, Barclays’ assets achieved US$2.42 trillion, and it ranked the seventh-largest bank

worldwide(Group,2014).

During the 2008 financial crisis, Barclays announced its agreement to purchase the

investmentbankingandtradingdivisionsofLehmanBrothers(White&Dash,2008)thatsame

year. In the end, Barclays PLC paid US$1.35 billion to acquire the core business of Lehman

Brothers, including Lehman’s US$960 million midtownManhattan office skyscraper and the

responsibility for 9,000 former employees (BZW - History - 21st Century - Lehman Brothers

Acquisition,2017).

Automated regression testing for any particularweb application involves using aweb

browsertoverifythatthewebappisworkingasexpected.Ifdonecorrectly,itcanincreasethe

effectiveness,efficiency,andcoverageofthesoftwaretesting.Timesavedtranslatesintocost

savings.Therearedifferent typesofsoftware tests thatcanbeautomated, forexample:unit

testing,functionaltesting,integrationtesting,regressiontesting,inwhichfunctionaltestingand

3|Dai,HoWu

regressiontestingarewhatrelatedtothisproject.

2.1CurrentGUIWebApplicationAutomationTestingFramework

The framework consists of three components, quality center, QTP, and Excel. Quality

Centerstoresthetestcases;QTPaccessesthewebbrowser(itexecutesthetests);Excelstores

the data during the execution; VBScript ties all the previous components together. All three

componentsaretiedtogetherbyVBScript.TheframeworkisshownbelowinFigure1.

Figure1:CurrentGUITestingFrameworkWorkflow

2.1.1QualityCenter

HPQualityCenterisHewlett-Packard'ssoftwarequalitymanagementproduct,partofthe

company'sapplicationlifecyclemanagement(ALM)softwaresuite. It isaweb-basedtoolthat

manages and drives efficient application testing processes. Quality Center stores all the test

cases. Following by descriptions, each test case is written step-by-step and comes with a

command function. The quality assurance team we are working with has all the command

functionsinVBScriptscriptinglanguage.QualityCenterclearlyshowstheobjectsbeingused,the

objectparents, and thevalue that isbeingapplied toeach function.By referring to the step

QualityCenter

Storethetestcases

QuickTestProfessional(QTP)

Accessthebrowserandtheobjects;functions

Excel

Storethetestdatausedinexecution

4|Dai,HoWu

names,thetestcasescanbeextractedfromthecorefunctions.Then,QTPcanruntheextractions

totesttheGUIWebapplication.Figure2isasamplescreenshotofQualityCenter.

Figure2:QualityCenter

2.1.2QTP/UFT

HPUnifiedFunctionalTesting,alsoknownasUFT,andpreviouslyknownasQuickTest

Professional, or QTP, is an automation testing tool. Barclays relies on this software to do

regressionandfunctionaltestforitsGUIWebapplications.QTPexecutesone-linecommandsto

get the objects. After getting the object, it then runs the test cases extracted from the core

functions,which in this caseareallwritten inVBScript scripting language.All theobjectsare

saved in theObjectRepository,which iswritten inQTPscripting language.Toget theobject,

testerscansimplyusethefunctionbelow:

Browser(“Google").Page(“Google").WebEdit(“q”)

ThisQTP functionwill thenbrowse theobjecton theGUIWebApp. Finally, bydoing

recordandplayback,QTPinspectsthequalityofGUIWebapplication.Figure3isasamplescreen

shotofQTP:

5|Dai,HoWu

Figure3:UFT/QTP

2.1.3VBScriptScriptingLanguage

VBScriptscriptinglanguageisusedtotietheentireframeworktogether.Barclayshasthe

core functions written in VBScript to extract the design steps of the test cases. After the

extraction, the command set,which is alsowritten in VBScript, then executes the functions.

Finally,thefunction“Get_Object”isusedinVBScripttocalltheORTranslatorinQTP.

2.1.4ORTranslator

Theobjectrepositoryisacentralizedlocationthatstoresalltestobjectsandelements

available from the application that are being tested alongwith its information or properties

(objects’information).Thesearelaterusedbythetestscripttoidentifyspecificitemsduringthe

executionofthetest.Storedobjectswithinanobjectrepositorycanbeanyoftheelementsthat

arepresentintheGUIWebapplications.TheseobjectscanbeanythingthatisvisibleontheGUI

(i.e.textfields,images,listitems,etc.).

2.1.5QTPObjectRepository

ObjectRepositoriesarecomposedofdifferentcomponents(Reilly&Tupelo-Schneck,2010):

● Object Identifiers: Everynewobject that is added to theobject repositorywill get an

individual identifier. The identifier helps the test scripts locate a specific objectmore

6|Dai,HoWu

easily.Afterlocatingthem,thetestscriptsproceedtoworkonthem.

● ObjectClass:Theobjectclassvalueisassignedbasedontheobject’stype.Everysoftware

hasitsrespectivesetofobjectclassvalues.Forexample,QTP/UFThasitsownbuilt-inlist

ofclassesfordifferentcategories(i.e.listbox,editbox,button,images,links,etc.).

● ObjectLocation:Theobjectlocationvaluedefineswheretheobjectisgoingtobestored,

regardlessofwhetheritispartofaLocalObjectRepositoryoraSharedObjectRepository.

● ObjectProperties:Objectpropertiesarethepropertiesandcharacteristicsthatareused

toidentifytheobjectsinaspecificapplication.

● VisualIdentifiers:Visualidentifiersaresetsofdefinitionsthathelpidentifytheobjectsby

usingtheobject’srelativelocationtoneighboringobjects.Visualidentifiershelpenhance

the process of identifying objects, which then helps reduce the probability of falsely

recognizinganobject.

● OrdinalIdentifiers:Ordinalidentifiersareadditionalpropertiesthathelpdifferentiatethe

objectsfromeachother.Therearethreekindsofordinalidentifiers:

1. Index:This indicates theorder inwhich theobjects showup in theapplication

relativetootherobjectswithanidenticaldescription.Itstartswithanindexof0.

2. Location:Thisindicatestheorderoftheobjectintheparentwindoworframe.

3. Creationtime:Thisindicatesthesequenceinwhichthebrowserisopened.

Afterknowingwhatanobjectrepositoryconsistsof,weneedtoacknowledgethatthere

are two different types of object repositories. First, there is a type called a Local Object

Repository,which is just available to a particular action. This kind ofOR employs a .mtr file

extension.TheobjectsaddedtoaLocalObjectRepositorycannotbeusedinanyotheraction,

7|Dai,HoWu

eveniftheyarethepartofthesametest.Inthistypeofobjectrepository,theobjectsarestored

foraparticularactionandonlythatparticularactioncanaccessitsrespectivestoredobjects.This

kindofrepositoryisbestsuitedforbackinguptestobjectsandforlearningnewobjects.Thiskind

ofrepositoryispreferabletotestnon-dynamicapplicationswithrespecttotime.Itisimportant

torememberthatallrepositoriesarelocalbydefault.ThefollowinglistisalistofLocalObject

Repositoryoperations:

● LocalObjectRepositorieshighlightanobjectstoredintherepository;

● LocalObjectRepositoriescheckwhetheraparticularobjectintheApplicationUnderTest

isstoredintheObjectRepository;

● LocalObjectRepositoriescut,copy,paste,modify,ordeleteobjects;

● LocalObjectRepositoriesupdateaproperty’sdescriptionfromtheapplicationusingthe

updatefunction,intherarecasewhereaproperty’svaluewaschangedbyaccident.

Thesecond typeofobject repository is calledaSharedObject repository,whichhasaglobal

scope.ThiskindofORusesa.tsrfileextensionandcanbeusedbymultipleactionsindifferent

tests.Thisflexibilitymakesthistheidealrepositorytypeforstoringandpreservingtestobjects.

InordertocreateaSharedObjectRepository,oneneedstofirstexportthelocalobjects.Before

beingabletousethe.tsrfile,itisnecessarytoassociatetherepositorytothetestbyclickingon

“Resources”andthen“AssociateRepository”.

2.2ProblemStatement

EmployeesintheBarclaysCorePrimeBrokeragehaveQTPlicensecontentionissuessince

notallofthemcanaccessQTPatthesametime.Thisinhibitsandaffectstheirworkefficiency.

Moreover,asthecostofQTPlicenseisexpensive,Barclayshasstoppedinvestinginnewlicenses

8|Dai,HoWu

forthissoftware.Therefore,thecurrentlicensecountisnotenough.Duetotheseissues,many

Barclaysemployeeshavecomplainedandreportedissueswiththesoftware.However,notmuch

hasbeendonesincetheyarestillworkingontestingprojectsfromGUIWebapplicationsthat

solelydependonQTP.Meanwhile,over1000GUIautomatedtestcaseswerecreatedusingQTP,

soallthesetestcasesneedtobepreserved.Thus,themainpurposeofthisprojectwastolook

forareplicablefreesoftware,whichcanpreservethelegacytestcaseswhilealsosolvingtheQTP

licenseissuesbyreplacingit.

9|Dai,HoWu

Chapter3:Methodology

3.1ImplementationCriteria

Afterinterviewingourmanagerandgatheringmoreinformationabouttheproblemsthe

teamhasfromusingQTP,fourcriteriawereidentified,whichmustbemetforanewfreeGUI

WebApplication automation testing tool to be implementedwithin the Barclays Core Prime

BrokerageQualityAssuranceteam:zero-cost,VBScriptscriptinglanguagesupport,open-source

software,andGUI-webapplicationtestingsupport.Anyfeasiblesolutionshavetobefree,open

source,whilesupportingboththeVBScriptscriptinglanguageandGUIwebapplicationtesting.It

isimportanttoacknowledgethatallcriteriaareequal.Anypossibleautomationtoolsthatmay

havefailedtomeetthestandardofeitheroneofthefourcriteriawereeliminated.

3.2ComparingExistingAutomationTools

As discussed in Section 2.1.2, theQTP tool is costly and is not open source. To start

replacing QTP, we identified nine alternative tools which could be used to test GUI Web

applications. These include Selenium WebDriver, Microsoft Coded UI Test, Test Complete,

Rational,iMacros,OracleApplicationTestingSuite,EggplantFunctional,Sahi,andMaveryx.Our

findingsaresummarizedinTable1.

10|Dai,HoWu

Table1:PotentialSoftwareComparisonTable

TodeterminethetoolwhichbestsatisfiesBarclayscriteria,wecreatedanindicatoras

seenbelow.Foreachcriterion,azeroindicatesthatanalternativedoesnotmeetthecriterion,

whileaoneindicatesthatitdoes.Forexample,a“1”iniMacrosintheVBScriptscriptinglanguage

criterionindicatesthatitsupportsVBScript.Thismeansthatbyusingthissoftware,alllegacytest

casescanbepreserved.Eachrow,whichisthescoreoneachcriterion,issummedattheend.

Thegreaterthescore,thebetterthetoolisintermsofbeingabletomeetBarclays’requirements.

Thetotalweightisthenaddedtothelastcolumnontheright.Bycomparingthetotalweight,we

boxedthehighest,whichinthiscaseisSeleniumWebDriver.Seleniumisthebesttoolsinceithas

azerocostandisanopensourcetool.ItalsosupportsGUI.AndbyusingJava,theVBScripttesting

scriptscanalsobeaccessedbySelenium.

11|Dai,HoWu

Table2:BestOptionAmongAllSoftwareTools

Tobetterillustratethecomparisonprocess,seeFigure4.Fromthisfigure,thebluebar

represents the cost, the orange bar represents the VBScript scripting language, the gray bar

denotesthatitisopensource,andtheyellowbardenotesGUIWebapptestingsupport.Thebar

chartshowstherelationshipofthefourcriteriawitheachtool.Withthehighestbar,Selenium

standsout.SinceSeleniumistheonlytoolthatfulfillsallfourcriteria,itis,therefore,theonly

feasiblesolution.Fortherestofthetools,theydidnotqualifyforatleastonecriterion.Theworst

optionsareRationalFunctionalandEggplantFunctional.Theonesclosetobecoming feasible

solutions are Microsoft Coded UI Test, Sahi, and Maveryx. A more detailed reason for the

eliminationprocesseswillbewritteninthenextsection.

12|Dai,HoWu

Figure4:WeightBarChartfortheAvailableAutomationTestingTools

3.3RationaleforEliminatingAlternatives

3.3.1MicrosoftCodedUITest

CodedUIusesMSAAandUIAtechnologiestoidentifyobjectsinanobjectrepository(or

whatmostcallUIMap),whileUFTusesacoded-injectionapproach.

CodedUIconductsatestintwoways:eitherbyrecordandplaybackorbyhandcoding.

Itmostly supports C# language and not VBScript.We looked into converting VBScript to C#

(Microsoft,2015).However,goingfromVBScripttoCodedUI'sobjectorientedC#isnotthateasy

as justaddingaplug-in.WhileQTP isa functionaltestingtool,CodedUI isusedmoreforunit

testing; thus, therearemanyarchitecturaldifferences.Dueto thesereasons, thisoptionwas

eliminated.

0

0.5

1

1.5

2

2.5

3

3.5

4

4.5

UnifiedFunctionalTesting(QTP)

SeleniumWebDriver

MicrosoftCodedUITest

TestComplete

RationalFunctional

iMacros OracleAppTestingSuite

EggplantFunctional

Sahi Maveryx

WeightBarChart fortheAvailableAutomationTestingTools

Cost VBScriptingLanguage Opensource GUIsupport

13|Dai,HoWu

3.3.2TestComplete

Test Complete is one of the few existing automation testing software that supports

VBScriptlanguage.However,itisaproprietaryfunctionalautomatedtestingplatformownedby

SmartBearSoftware.Theyearlycostis$7000foronelicense(SmartBear,2017).Wediscarded

thisoptionasourfocusistofindtoolsthatarefreeandopen-source.

3.3.3RationalFunctional

RationalFunctionaltesterisfromtheRationalSoftwaredivisionofIBM.Itdoesprovide

automated testing capabilities for functional, regression, GUI, but as it only satisfied one

criterion,itwastheneliminated.ThissoftwareprovidesnosupportforVBScript.

3.3.4iMacros

iMacroscanrecordandreplayrepetitiousworkandistheonlywebautomationsoftware

thatmostlyworkswith everywebsite.However, it is not an open source software tool, and

therefore,notafeasiblesolutionthatwecanconsider.

3.3.5OracleApplicationTestingSuite

The Oracle Application Testing Suite CD-ROM includes the Microsoft® Visual Basic®

ScriptingEdition(VBScript)LanguageReferencedocumentation.Itisarareexistingsoftwarethat

supportsVBScript(Oracle,2008).AlthoughitsupportsbothVBScriptlanguageandGUIWebapp

testing,itisneitherfreeoranopensourcetool.

3.3.6EggplantFunctional

EggplantFunctionwaseliminatedasitonlysatisfiedthecriterionofGUIWebapptesting.

ThescriptinglanguageitusesiscalledSenseTalk(TestPlant.com,2017);therefore,itwouldnot

14|Dai,HoWu

bepossibletousetheVBScripttestingcasescurrentlyinexistence.

3.3.7Sahi

SahiisanopensourcetoolfortestingGUIWebapplicationsthatworksoneverybrowser.

ItalsosupportstheVBScriptscriptinglanguage.However,theonlydeficiencyisthatitisonlyfree

toaccesstheSahiOS.However,eventhoughitisfree,SahiOSonlyincludeslimitedfeatures.To

gettheaccesstoallofSahi’sfeatures,itismandatorytopurchaseSahiPro,whichcosts$695for

alicense(Pro,2017).Duetoitsimminentcost,thisoptionwastheneliminated.

3.3.8Maveryx

Maveryx is an automated functional and regression test tool for Java and Android

applications.We researched this tool because almost all theGUIWeb apps thatwe have in

BarclaysarewritteninJava.Thesoftwareonlyfreewhenrunningonafree-trialmode,meaning

thatitofferslimitedfunctionsforalimitedtime.ForalargefirmlikeBarclays,thiscannotbea

long-termsolution.

Afterresearchingeachofthesetools,thereisonlyoneremainingalternative,whichis

SeleniumWebDriver.Itistheonlyfeasiblesolutionthatsatisfiesallfourcriteria.Thefollowing

sectionswilldiscussmoreabouthowtoreplaceHP’sQTP/UFTwithSeleniumWebDriver.

15|Dai,HoWu

Chapter4:TwoFeasibleAutomationTools

ThischapterwillspecificallyexplainhowSeleniumWebDriverworksandunveilanother

feasiblesolutionapartfromusingtheexistingsoftwaretool. Itwillcoverthebackground,the

workingprincipleofeachfeasibletool,andnumerouswaystoreplacetheObjectRepositorythat

isfoundinQTP.ThereasonwhyitisimportanttofocusonQTPObjectRepositoryisbecauseitis

thecoreprocessthatneedstobereplaced.Tobespecific,itistheonlypartthatisnotwrittenin

VBScriptandthatdirectlyconnectstoQTP.Additionally,theotherpartsofthetestingframework

areeasiertofixiftheobjectrepositoryimplementationissolved.

4.1Alternative#1:SeleniumWebDriver

4.1.1Background

Seleniumisanopen-sourcetoolthatiscommonlyusedfortestautomationparticularly

intheFinancialServicesIndustry.SeleniumWebDriverwasfirstintroducedinSelenium2.0and

itdirectlycalls thebrowsersbyusing thebrowser’snativesupport forautomationandother

browser-specificfeatures.Itsuniqueplatformandlanguageneutralinterfaceallowsforamore

seamlesscontrolofaWebbrowser.HowSeleniumWebDriverworksisshowninFigure5below:

16|Dai,HoWu

Figure5:SeleniumWebDriverWorkingPrinciple

4.1.2BrowserCompatibility

Browsershavedifferentcompatibilities.Forexample,MozillaFirefoxsupportsWebDriver

bydefault.However,Chromeand IE (32-bitsand64-bits) requirea specificexecutabledriver

(SeleniumHQ,2014).Tosolvethisproblem,thefirststepistodownloadtheexecutabledriver

fromGoogle’sChromiumwebsite

(https://sites.google.com/a/chromium.org/chromedriver/downloads)

andincludethefollowinglineofcodeintoSelenium:

System.setProperty("webdriver.chrome.driver","/path/to/chromedriver");

EventhoughSeleniumWebDriversupportsmultiplebrowsers,wewillbefocusingmore

onIEandGoogleChromeasBarclaysonlysupportsthesetwo.Havingsaidthis,itisimportantto

17|Dai,HoWu

considerthepossibilityofadoptingaheadlessbrowsertestingmodelorabrowsersimulator(i.e.

HTMLUnit)sinceSeleniumWebDriveralsosupportsthis.Significantprocessingresourcescanbe

savedbyusingaheadlessbrowser.Andsinceallthefunctionswouldruninthebackground,this

would then create an even more seamless and “real” automated testing environment.

Additionally,onecouldstartautomatingonaheadlessserver(i.e.continuousintegrationservers

suchasJenkins).

4.1.3CallingJavabyUsingVBScript

TopreservetheexistingtestingcodethatiswritteninVBScript,wehadtofindawaytolink

JAVAandVBScripttogetherforthefollowingreasons:

1. SeleniumcannotuseVBScriptdirectly,butSeleniumcanuseJAVA;

2. JAVAisoneofthemostcommonlyusedscriptinglanguagesnowadays;

3. ItispossibletoconnectJAVAwithVBScript.

Before proceeding, we have to identify how Selenium would preserve VBScript. After

researching,wefoundthatwecanuseJAVAtogettheobject,andthenuseVBScripttocallJAVA.

Togettheobject,thecodewecanapplyinJAVAisshownbelow:

WebDriverdriver=newChromeDriver()

WebElementelement=driver.findElement(By.name("q"));

element.sendKeys(“test”)

ThisspecificcodeisshowninAppendix1.Appendix1istheextensionofthecodeseen

above.Whereasthecodeabovejustcontainsthemainfunctionsthatperformtheexecutions.

18|Dai,HoWu

Aftergettingtheobject,weusethecodeinVBScripttocalltheJAVAcodeinordertotestthe

objectsfoundsinthetestcasesthatarewritteninVBScript.ThecodetoinvokeJAVAbyusing

VBScriptisshowninAppendix2.AllthecodefoundintheAppendicesarewrittenwiththehelp

ofourmanager,KarleneWright.

4.1.4InstantiatingaSpecificBrowser

Toinstallaspecificbrowser,weneedtocreateabrowsernamebyaddinganewdriver.

ThispieceofcodeiswritteninJava.Thewebbrowsernamescanbe:Firefox,Chrome,Safari,or

InternetExplorer.Thecodeisshownbelow:

WebDriverdriver=new“BrowserName”Driver();

ToaccessawebpageinSelenium,weneedtouseWebDriverandHtmlUnitDriver

classes:

WebDriverdriver=newHtmlUnitDriver();

WebElementelement;

Moresamplecodetoopenabrowser,whichcheckstoseewhichbrowser iscurrently

beingusedisshowninAppendix3.ThesamplecodetoruntestcasesinGoogleChromeusing

SeleniumWebDriverandthesampleJavacodeimplementingaGooglesearchinSeleniumare

alsoincludedinAppendix3forreference.

4.1.5OtherWaystoGettheElementsbyUsingSelenium

TherearemultiplewaystogettheelementsinSelenium.SeleniumusesJAVAtogetthe

object,sothemostcommonlyusedfunctionisthe".FindElement"functionfoundinJAVA.The

19|Dai,HoWu

".FindElement" function can be used in different ways to access the objects. Inmost cases,

programmersfindtheelementusingtheobject'snameandID.Sometimes,theelementscanalso

befoundbyusingClassName,Tagname,LinkText,partialLinkText,orXPath.Thecodetofindan

elementthroughthenumerousaforementionedwayscanbefoundinAppendix4.

4.1.6HowtoImplementanObjectRepositoryinSelenium?

Itishardtolookforanobjecteverytimewhenweneedtotestit.However,it'seasyforQTP,

becauseithasanintegratedobjectrepositorythatstoresalltheobjects.Ifwearegoingtouse

theSeleniumWebDrivertoreplaceQTP,wehadtofindawaytostoretheobjectsinorderto

make iteasiertofindtheobjects.Afterconductingourresearch,wefoundthreemethodsto

applyanobjectrepositorywithinSelenium:

1. WecanstoretheORinanExcelfile(.xml),justlikeQTPdoes.

2. Wecanusepropertiesfiles.

• Thismethoduseskey-valuepairformat,whichtendstobemorereadableby

thesoftware.

3. WecanapplythePageObjectModelorPOM.

• ThismethodwillensuretheOR’sstructureissimilartoQTP’sORstructure.It

alsomeansthatthefinalcommandwilllookexactlylikeaQTPcommand.

Tofurtherexplainhowthesethreepossibleways,howtheywork,andhowtousethemto

executetheobjectrepository'swork,wedetailedeverythingbelowstepbystep:

Excelfile(.xml)

AnexampleofanXMLbeingusedasanobjectrepository,includingcoderetrievaland

20|Dai,HoWu

execution,isshowninAppendix5.

PropertyFiles

BackgroundaboutPropertyFiles

WecancreateanobjectrepositorybyrelyingonthepropertiesfilefeaturefoundinJava.The

.propertiesfileinJavaisjustabasiccollectionofkey-valuepairs.Therefore,theORcouldthen

beimplementedasacollectionofkey-valuepairs,withthekeybeingalogicalnameidentifying

theobjectandthevaluecontaininguniqueobjectspropertiesusedtoidentifytheobjectona

screen. This can be achieved by comparing the file’s properties to a specific format that is

recognizedbytheclassjava.util.Properties.TherulesoftheJavaPropertiesareasfollows(ATG,

2016):

1. Entriesaregenerallyexpectedtobeasinglelineoftheform,eitheroneofthefollowing

two:

o propertyName=propertyValue

o propertyName:propertyValue

2. Whitespacethatappearsbetweenthepropertynameandthepropertyvalueisignored,

asexemplifiedbelow:

o name=Stephen

o Whitespaceatthebeginningofthelineisalsoignored.

3. Lines that startwith the comment characters ! or # are ignored. Blank lines are also

ignored.

21|Dai,HoWu

4. Thepropertyvalueisgenerallyterminatedbytheendoftheline.Whitespacefollowing

thepropertyvalueisnotignoredandistreatedaspartofthepropertyvalue.

5. A property value can span several lines if each line is terminated by a backslash (‘\’)

character.Thiscanbeseenbelow:

targetCities=\

Detroit,\

Chicago,\

LosAngeles

This isequivalent to targetCities=Detroit,Chicago,LosAngeles. In this case,wehave to

rememberthatthewhitespaceatthebeginningofthelineshastobeignored.

6. Thecharacter’snewline,carriagereturn,andtabcanbeinsertedwithcharacters\n,\r,

and\t,respectively.

7. Thebackslashcharactermustbeescapedwithadoublebackslash.This isexemplified

below:

path=c:\\docs\\doc1

Oneimportantthingtonoteisthefactthatitisnotnecessarytoescapebackslashesin

property values when using the ATG Control Center Components window; the ATG

ControlCenterwillhandletheescapecharactersautomatically.

8. UNICODEcharacterscanbeenteredastheyareinaJavaprogram,usingthe\uprefix.For

example,“\u002c”.

WecanusetheJavainterfaceinSeleniumtoreadtheobjectpropertiesintovariablesand

thenhavethescriptsreferencethevariablespresent inthe interface.Todoso,wemustfirst

decidetheformatofthepropertiesfile.Afterthat,wecanstorealltheelement locators ina

22|Dai,HoWu

.XMLfileasanobjectrepository.However,onedrawbackofthismethodisthatitmighttakea

longtimetomanuallycreateallthepropertyfiles.Asamplepropertiesfileformatisthefollowing

one(Chavan,2016):

[logical_name]=[locator_type]~[locator_value]

Thedefinitionofeachtermisshownbelow:

[logical_name]:Thelogicalnamegenerallywouldbelabelofelement.[AsdisplayedontheUI]

[locator_type]:Thelocatortypemustbeonefromthefollowingtypes:id,name,className,

linkText,partialLinkText,cssSelector,xpath,tagName.

[locator_value]:Thisisthelocatorvalue,orthevalueoflocator_type

Thisishowthepropertyfilewouldenduplookinglike,asseeninFigure6:

Figure6:SamplePropertyFile

CreatingtheObjectRepositoryinSelenium(CodeforRunningaSimpleBingSearch)

TocreateanobjectrepositoryinSeleniumbyusingthepropertiesfile,weneedtowrite

thecodefordoingtheBingsearch. Inthisparticularcase,aBingsearchscriptwouldneedto

manipulatethreescreenobjects:

● Thetextboxwherethesearchstringistyped;

● Thesearchbuttonthatisclickedtosubmitthesearchquery;

23|Dai,HoWu

● Thetextfieldthatdisplaysthenumberofsearchresults

Theobjectmapwillbeasimple.propertiestextfilethatwecanaddtoourSeleniumproject,

asseeninFigure7:

Figure7:ObjectMap

Thekeyforeachobject,i.e.bing.homepage.textbox,isalogicalnamefortheobjectthat

wewilluseinourscript.Thecorrespondingvalueconsistsoftwoparts:theattributetypeused

foruniquelyidentifyingtheobjectonscreenandthecorrespondingattributevalue.Forexample,

the aforementioned text box is uniquely identified by its id attribute, which has the value

sb_form_q.

RetrievingandFetchingObjectsfromtheObjectRepository

Toretrieveobjectsfromanewlycreatedobjectmap,wewouldneedtodefineaclass,

ObjectMap,withaconstructorthattakesasingleargument,whichisthepathtothe.properties

file. Details on how to write an object map can be referred to Appendix 5. Objects can be

identified using a number of different properties (i.e. object IDs, CSS selectors and XPath

expressions).

HowCanWeUsetheObjectsfromanObjectMap?

Afterbeingabletoretrieveobjectsfromtheclassobjectmap,wecanstartusingthese

24|Dai,HoWu

objectsinthescriptaspartofthefunctions.Thecodetoexecutethemethodofaccessingan

objectrequiresaveryeasyandsimplestep:Thisstepinvolvesreferringtothekeyintheobject

map.ThisisalsocalledaslogicalnameandthiscodeisshowninAppendix6.

PageObjectModel

Background

Abetterapproachtoscriptmaintenanceistocreateaseparateclassfile,whichcanthen

findwebelements,fillthem,orverifythem.Thisclasscanbereusedinallthescriptsthatusethe

sameelement.Inthefuture,ifthereisanychangeinthewebelement,wewouldthenneedto

makechangeinjustoneclassfileandnotinalltendifferentscripts.ThisapproachiscalledPage

ObjectModel(POM).Thisapproachhelpsmakecodemorereadable,maintainable,andreusable.

The principle of POM is showed below, in Figure 8. If implemented properly, POM can help

organizethecode,reducemaintenanceefforts,andreducescriptcreationtime.

Figure8:ThePrincipleofthePageObjectModel

● InaPOMmodel,eachwebpageintheapplicationmusthaveacorrespondingpageclass.

● Thispageclasswillfindthewebelementsofthatwebpageandwillalsocontainafunction

25|Dai,HoWu

thatwillperformoperationsonthewebelements.

AdvantagesofthePageObjectModel

Thecodeiscleanerandeasiertounderstandbecausethestructurerequiresthatallthe

UI operations and flows be separated from verification. In addition, theObject Repository is

independentofthetestcases.ThesameORcanbeusedfornumerouspurposesandnumerous

tools.Lastbutnotthe least,giventhefactthattheORcanbereused,theamountofcode is

therebyreducedandoptimizationcantherebybeattained.

HowtoSetPOMUp?

FollowthestepsbelowtosetthePOMupandthecodecanbefoundinAppendix7:

1. Rightclickon‘x‘packagethenselectNew>Classandnameitas“ProductListing_Page”.

2. Createanotherpublicstaticclassinsidetheaboveclass‘x‘andnameitasProduct_1.

3. NowcreatedifferentStaticMethodsforeachchildelementofProduct_1.These

methodswillneedanArgument(WebDriver)andaReturnvalue(WebElement).

Totestthecode:TypeProductListing_Pageinthetestscriptandpressdot.Thiswilldisplay

alltheproductswehavespecifiedintheclass,asseeninFigure9.

Figure9:ExampleofaPageObjectModelinAction

SelectProduct_1andpressdotagain.Thiswillnowdisplayallthechildelements

26|Dai,HoWu

associatedwiththeparentProduct_1,asseenbelowinFigure10:

Figure10:ChildElementsintheProduct

TheresultingcommandlineisQTP-like:

ductListing_Page.Product_1.btn_AddToCart(driver).click();

4.2Alternative#2:UsingInternetExplorerObject

4.2.1Background

Internet Explorer Objects contains three types of members: Events, Methods and

Properties.VisualBasiccanaccessthisfunctionalitysinceInternetExplorersupportsautomation.

Forexample,thefunction“CreateObject”canbeusedinVisualBasictolaunchaninstanceof

InternetExplorer.

4.2.2HowDoesItWork?

Forexample,let’screateaVBScriptthatcanbeusedtotestaGooglewebpage.Toaccess

theGooglewebsiteURL,wehavetwopiecesofcodesinVBScriptthatareattachedinAppendix

8.Specifically,weusetheInternetExplorerObjecttocontrolaninstanceofWindowsInternet

27|Dai,HoWu

Explorerthroughautomation.Then.applicationgetstheautomationobjectfortheapplication

thatishostingthewebbrowsercontrol.Finally,weusethe“Navigate”functiontonavigatethe

resourceidentifiedbyaURL.InadditiontograbbingobjectsthroughtheURL,wealsoresearched

thewaytogetobjectsbyID.ThesecodesareshowninAppendix8.Additionally,wecanalsoget

thewebbuttonandthewebtablebyusingasimilarcodeinVBScript,which isalsoshownin

Appendix8.

4.2.3HowtoImplementtheObjectRepositoryintheIn-houseDevelopmentTool?

Therearetwomethodstostoretheobjects:UsingeitherExcelorthereferencedialogbox

method.

Excel(.XML)

Similartotheobjectrepository,whichisoriginallyintroducedinQTP,wecancreateour

ownobjectrepositorybycreatinganXMLfile.Tocreateourownobjectrepository,therearetwo

methods that can be used: Either using "ObjectRepositoryUtil Object" or using the object

repositorymanager.Then,wecanworkwithobjectrepositoryfiles(Local/Shared)fromoutside

ofUFT.

Forthefirstmethod,toconvertanobjectrepositoryinto.XMLformat,weeitherenter

"ObjectRepositoryUtil" in the searchboxunderneath the Index tabor use the code found in

Appendix8.

Forthesecondmethod,wecansimplyexportthe.XMLfile,byusingtheobject

repositorymanager.Wedosoby:

1. Toopentheobjectrepositorymanager,clickonResources

28|Dai,HoWu

andthenclickingonObjectRepositoryManager

Figure11:ObjectRepositoryManager

2. OpeningtheObjectRepository,thenclickingonFile,andthenopen

3. Toexportto.XMLformat,clickonFileandthenonExporttoXML

Figure12:ExportingtheXMLFile

ToaddtheobjectbyusingVBScript,weloadanexistingobjectrepositoryandusethe

AddObjectfunctiontoaddanobjecttoit.Thisisanexampleofhowwecanaddtheobjectby

usingVBScript.Soreversely,itisalsopossibletogettheobjectbyusingVBScript.Thedetailed

codeisattachedtoAppendix9.

Additionally,thereisanotherwaythatcanbeusedtogettheobjectfromXMLfile.The

codeforthiswayisalsoattachedtoAppendix8.

29|Dai,HoWu

ReferenceDialogBox

WecanmaketheobjectsintheInternetExploreravailabletoVisualBasic4.0throughthe

referencedialogbox.ThereferencedialogboxlistsalltheobjectsavailabletoVisualBasic.The

dialogbox canbe accessedby selecting Tools/References from themenubar. The reference

dialogboxhasareferencesettothe InternetExplorerobject library.Theproperreference is

describedinthedialogboxas"MicrosoftInternetControls."

OnceareferenceissetinVisualBasic,wecanstartexploitingtheobjectsinthecode.For

example,togetaninstanceoftheInternetExplorerbrowser,whichcanbeaccessedfromVisual

Basic,wecouldusethefollowingcode:

DimMyBrowserAsSHDocVw.InternetExplorer

SetMyBrowser=NewSHDocVw.InternetExplorer

Thereferencedialogboxallowsustoselectanotherapplication'sobjectsthatwewant

availableinourcodebysettingareferencetothatapplication'sobjectlibrary.

4.3ComparingtheTwoFeasibleSolutions

4.3.1SeleniumWebDriver

Using Selenium’s WebDriver would be beneficial in the long run given the fact that

Selenium’sWebDriverspecificationiscurrentlyindraftformtobecomeaW3C(WorldWideWeb

Consortium)WebStandard. Thiswillmean that anywebbrowser software vendorwouldbe

required to supportSeleniumWebDriverbyhaving theirown implementationof it.Although

Seleniumhasitsownscriptinglanguage,itisnotrestrictedtowriteinthatlanguagesinceitcan

work with other language bindings to support whatever scripting language the testers are

30|Dai,HoWu

comfortable with, including C#, Java, JavaScript, PHP, Python, among others. Additionally,

Seleniumoffers record-and-playbackcapabilities.Becauseof the rapid testdevelopment that

Seleniumenables,itisquitepopularforquick-cycledevelopmentmethodologiessuchasAgileor

ExtremeProgramming.Moreover,SeleniumisalsopopularwithITstaffwhoautomaterepetitive,

web-based administrative tasks. Furthermore, Selenium supports most operating systems,

amongthemWindows,Macintosh,Linux,Unix,andetc.Also,Seleniumcanbeintegratedwith

JenkinsorHudson for continuous integration (Kumykov, Luo, Shoop,&Zhang, 2016). Finally,

SeleniumcanbeusedforAndroid,iPhone,Blackberry,andetc.basedapplicationtesting,which

meansthatitwillbeusefulshouldBarclaysstartadoptingmobileGUIwebapps.

Despite itsnumerousfeatures,Seleniumisnotacomplete,comprehensivesolutionto

fully automate the testing of web applications. It requires third-party frameworks, language

bindings,andsoon tobe trulyeffective.Becausenative“Selenese” test scriptsarenotuser-

friendlyintermsofreadability,theyaredifficulttomodify.Additionally,Seleniumhastechnical

issues with browsers which are not Mozilla Firefox. Furthermore, it does not support

conditionals,loops,andhastroublefindinglocatorswithoutthehelpofadditionaltoolssuchas

Firebug.

4.3.2InternetExplorerObject

Ontheotherhand,allofBarclays’testcasesareeasiertodebugusingInternetExplorer

Object,becauseeverythingwouldbebuiltin-house.Itisveryuser-friendlytochoosetoapplyin-

housedevelopment toolbecauseall codeswillbewritten inone language,which isVBScript

language.SinceVBScriptisverysimilartoQTPlanguage,itiseasiertotranslatetheQTPpartof

31|Dai,HoWu

code.ItwouldalsobeeasierfortheVBScriptexperiencedstafftohandlethenewtoolsincethey

alreadyknowhowtowriteinVBScript.Additionally,thecodestogetdifferentobjectsinQTPare

similartothecodesusedinInternetExplorerObject,soitwouldbemoresimpletomanage.

However, there are alsodisadvantagesof using this in-housedevelopment tool. First,

Barclayswouldhavetomanuallywriteallthefunctionstooperatetheentiretestingframework.

Thiswouldindirectlycostthecompanymoneyastheyneedtohireandtrainpeopletowriteall

thefunctionsandbuildtheentirelibrary.Itwillalsotaketimetodevelopanewin-housetool,

eventhoughwehaveageneralideaonhowtogetthisdone.Finally,itishardertodebugthe

codeduetothelackofwideronlineusercommunity.Inordertocheckthebug,wewouldhave

torunthecodeandthencheckfortheerrormanually.

32|Dai,HoWu

Chapter5:RecommendationsandConclusions

5.1Conclusion

Aftercomparingthetenalternatives,thereisonlyonetoolsatisfiesall fourcriteria⎯

SeleniumWebdriver.ByusingSeleniumWebdriverasanautomationtestingsoftware,wefirst

needtowritecodetousetheprogramminglanguageJAVAtogetobjects.Then,weneedtolink

JAVAtoVBScriptbyinvokingJAVAfilesbyusingcodethatwouldbewritteninVBScript.Tofully

replacethecurrentBarclaystestingtool,QTP/UFT,weresearchedthreewaystoreplaceobject

repositorytomaintainthefunctionalityofstoringobjectspresentinQTP.

However, the main disadvantage of Selenium is the inconsistency of obtaining the

objects.Thus,wecontinuedresearchingandfoundawaytodevelopanin-housedevelopment

toolbyusingInternetExplorerObject.Inthisway,wecanuseVBScripttogettheobjectinstead

ofusingQTP/UFT.Thereisnoneedofanypluginstoconnectthe“getelement”functionswith

the testing cases since all test cases arewritten in VBScript. Thiswould largely increase the

systemconsistencyandsavetheteamtimetostudynewprogramminglanguages.Thiswouldbe

thebestsolutionintheshortrun.

In comparing SeleniumWebDriver against Internet ExplorerObject, Seleniumhas the

advantages of increasing the efficiency of web application testing, having a function library,

supportingmultipleoperatingsystem,anddraftingtobethestandardoftheWorldWideWeb

Consortium,which outweigh the advantages of Internet Explorer Objects, which is easier to

debugandmoreconsistenttoruntheVBScripttestcases.

33|Dai,HoWu

5.2Recommendations

Intheshortrun,wesuggesttocreateanin-housedevelopmenttoolbyusingtheVBScript

scripting language, because it ties better to our current testing framework. In addition, the

VBScriptlanguageistheQTP-likedscriptinglanguage.ItiseasiertoconverttheQTP/UFTpiece

ofcodetoVBScriptlanguage.Nootherprogramminglanguagewouldinterferewiththechanges.

As a consequence, the migration from QTP to the in-house development tool can happen

smoothly.

However, in the long run, we suggest replacing QTP/UFT with Selenium WebDriver,

becauseit isatrendthatallmanualtestsaregoingtobeautomated.Especiallyfordoingthe

regressiontestthatneedstobeexecutedoverandoveragain.Theseleniumwouldbeusefulin

thelongterm.IfBarclayswilldevelopthemobileGUIwebappinthefuture,SeleniumWebDriver

would alsobeuseful for the testingpurposes. In addition,we recommend the team to start

writingtestingcasesinJavaanduseSeleniumWebDriverforGUIWebapptestingpurposesin

futurenewprojects.

EventhoughSeleniumWebDriversupportsmultiplebrowsers,wewillbefocusingmore

onIEandGoogleChromesinceBarclaysonlysupportsthesetwo.Havingsaidthis,itisimportant

toconsiderthepossibilityofadoptingaheadlessbrowsertestingmodel,orabrowsersimulator

(i.e.HTMLUnit)sinceSeleniumWebDriveralsosupportsthis.Significantprocessingresourcescan

besavedbyusingaheadlessbrowser.Andsinceeverythingwouldruninthebackground,this

would then create an even more seamless and “real” automated testing environment.

Additionally,onecouldstartautomatingonaheadlessserver(i.e.continuousintegrationservers

34|Dai,HoWu

suchasJenkins).

Throughtheserecommendations,wehopethatitwouldsavetheteamtheyearlycostof

theirUFTlicensesandpreventanyotherexecutionissuesthattheyarecurrentlyfacingwhen

dealingwithUFT.TheserecommendationscouldeventuallybeusefultootherBarclaysteams,

shouldBarclaysdecidenottouseUFTinthefuture.

35|Dai,HoWu

Chapter6:ReflectingonourExperienceatBarclays

6.1DiscussionofDesignintheContextoftheProject

OurprojectatBarclayswasanopportunityforustoapplywhatwehavelearnedatWPI.

WPIchallengedustothinkcriticallyandtoworkinafast-pacedenvironment.Thisallowedusto

adaptmoreeasilyintoBarclay'schallengingworkingenvironment.Asamajorglobalinvestment

bankwithalonghistory,Barclayscontinuouslystrivestobeaforward-thinkingorganizationina

highlycompetitive industry.Duetodemandingnatureofthebusiness,Barclaysplacesa large

emphasis on employing cutting-edge technologies, while still striving tomaintain the legacy

systemstheyhaveinplace.InordertofurtherBarclays'cutting-edgetechnologies,weworked

withthequalityassuranceteamtoimprovetheircurrentGUIautomationtestingframework.

6.2DiscussionofConstraintsConsideredintheDesign

Atthebeginningoftheproject,weweretaskedtofindanalternativeautomationtool

thatcouldreplacethecurrenttestingsoftwareinordertoreducecostsandincreaseusability.To

achievethis,wehadtodevelopedseveralpotentialsolutionstotheissue.Beforewestartedour

research, we had to better understand the demands and constraints of this project. After

consultingsubjectmatterexperts,wedevisedfourconstraintsthathelpeduscomeupwitha

solutionthatwouldnotonlysatisfytheirneeds,butalsobefullycompatiblewiththeirlegacy

code.

Weexploredsoftwaretoolsthatwereopensourceandeasilymodifiable.Byusingafree

andopen-sourcesoftware,wepotentiallysavedthecompanytensofthousandsofdollarsintheir

web application development. Additionally, we ensured that our solutions would support

VBScriptscriptinglanguagebecauseexistingtestcaseswerewritteninthislanguage.

36|Dai,HoWu

6.3DiscussionoftheNeedforLife-longLearning

Embedded within WPI's motto, "Lehr und Kunst", is the idea of embracing lifelong

learning.Learningdoesn'thavetostopaftergraduation.Itisnotconfinedtoacademiclearning,

sinceitalsomeansapplyingwhatwehavelearnedinordertoimproveourlivesandthelivesof

thosearoundus.

Fortheproject,afterreviewingtheoriginalframeworkofthetestingprocess,wewere

abletocomeupwithsolutionsthatwouldsatisfytheconstraintsgiventouswhilestillachieving

the intendedgoal.We learnedthat insuchacomplexenvironment, it ishardtoeradicateall

legacycode.

DespitethefactthatwecouldnotupgradetheentireGUIautomationtestingframework,

wefeelthatourprojectwasasuccessnonetheless.Allinall,wewereabletogrowandseethe

importanceofapplyingtheknowledgeandskillsinstilledonusbyWPI.Wewereabletowitness

firsthandtheimportanceofaproject-basedcurriculumanditseffectsinfosteringeffectivecareer

development.

37|Dai,HoWu

WorksCited

ATG,O.(2016).OracleATGProgrammingGuide.Retrieved15,2017,fromhttps://docs.oracle.com/cd/E23095_01/Platform.93/ATGProgGuide/html/s0204propertiesfileformat01.html

BZW-History-21stCentury-LehmanBrothersAcquisition.(2017).Retrieved15,2017,fromWikipediaAcquisition(CreativeCommons):http://www.liquisearch.com/bzw/history/21st_century/lehman_brothers_acquisition

Chavan,A.(2016,716).Saturday,July16,2016HighlightElementinSeleniumWebDriver.Retrieved1214,2016,fromQualityPerspective:https://qaperspective.blogspot.com/2016_07_01_archive.html

Delaware,B.B.(2016).Barclaysbankinghistory.Retrieved12,2017,fromBarclays:https://www.banking.barclaysus.com/our-history.html

Group,C.O.(2014).Barclays.Retrieved12,2017,fromOMICSInternational:http://research.omicsgroup.org/index.php/Barclays

IBM.(2016,3).RationalFunctionalTester.Retrieved112,2016,fromIBMSoftware:http://www-03.ibm.com/software/products/en/functional

Kumykov,K.,Luo,T.,Shoop,A.K.,&Zhang,B.(2016,1).DevelopmentofanOperationalProcessforContinuousDelivery.Retrieved12,2017,fromWPI:https://web.wpi.edu/Pubs/E-project/Available/E-project-012216-150216/unrestricted/WallSt_Barclays2_MQP.pdf

Microsoft.(2015).UseUIAutomationToTestYourCode.Retrieved1112,2016,fromMicrosoftDeveloperNetwork:https://msdn.microsoft.com/en-us/library/dd286726.aspx

Oracle.(2008).OracleApplicationTestingSuite.Retrieved1125,2016,fromOracleTechnologyNetwork:http://www.oracle.com/technetwork/oem/app-test/index.html

Pro,S.(2017).TheTester'sWebAutomationTool.Retrieved13,2017,fromSahi:http://sahipro.com/

Reilly,S.,&Tupelo-Schneck,R.(2010,1).DigitalObjectRepositoryServer:AComponentoftheDigitalObjectArchitecture.Retrieved1221,2016,fromD-LibMagazine:http://www.dlib.org/dlib/january10/reilly/01reilly.html

SeleniumHQ.(2014).SeleniumHQBrowswerAutomation.Retrieved1125,2016,fromhttp://www.seleniumhq.org/about/platforms.jsp

Software,S.(2017).AutomatedSoftwareTestingTestCompletePlatform:TestingForDesktop,Mobile,Web,&PagedApplications.Retrieved101,2017,fromSmartBear:https://smartbear.com/product/testcomplete/overview/

38|Dai,HoWu

TestPlant.com.(2017).eggPlantFunctional.Retrieved103,2017,fromTestPlant:http://www.testplant.com/eggplant/testing-tools/eggplant-developer/

White,B.,&Dash,E.(2008,917).BarclaysReaches$1.75BillionDealforaLehmanUnit.Retrieved1223,2016,fromNewYorkTimes:http://www.nytimes.com/2008/09/18/business/worldbusiness/18barclays.html

39|Dai,HoWu

Appendix1

UsingJAVAtogettheobject:

packagemypackage;

importorg.openqa.selenium.By;

importorg.openqa.selenium.WebDriver;

importorg.openqa.selenium.WebElement;

importorg.openqa.selenium.support.ui.ExpectedCondition;

importorg.openqa.selenium.chrome.ChromeDriver;

importorg.openqa.selenium.support.ui.WebDriverWait;

publicclassmyclass{

publicstaticvoidmain(String[]args){

System.setProperty("webdriver.chrome.driver","C:\\selenium-java-2.35.0\\chromedriver_win32_2.2\\chromedriver.exe");

WebDriverdriver=newChromeDriver();

driver.get("http://www.google.com");

WebElementelement=driver.findElement(By.name("q"));

element.sendKeys("Cheese!");

element.submit();

//driver.close();

}

}

40|Dai,HoWu

Appendix2

VBScriptcodeinvokingJAVA:

callPerformSearch("qtpvbsdemojar.jar","Search","C:/wpiintern/IEDriverServer.exe","http://www.google.com","Google","test")

PublicSubPerformSearch(sJarFile,sFunction,sPath,sURL,sTitle,sInput)

sCmdString="java-jar"&Chr(34)&sJarFile&Chr(34)&""&trim(sFunction)&""&_Chr(34)&sPath&Chr(34)&""&Chr(34)&sURL&Chr(34)_&""&Chr(34)&sTitle&Chr(34)&""&Chr(34)&sInput&Chr(34)

sError=ExecCmdString(sCmdString)

EndSub

PublicSubPerformSearch2(sFunction,sJarFile,sMainFunction,sFunc,sPath,sTitle,sInput)

sCmdString="java-cp"&Chr(34)&sJarFile&Chr(34)&""&trim(sMainFunction)&""&_Chr(34)&sFunc&Chr(34)&""&Chr(34)&sPath&Chr(34)&""&Chr(34)&sURL&Chr(34)_&""&Chr(34)&sTitle&Chr(34)&""&Chr(34)&sInput&Chr(34)

sError=ExecCmdString(sCmdString)

EndSub

PrivateFunctionExecCmdString(sCmdString)

SetoExec=CreateObject("WScript.Shell")

SetoOutExec=oExec.Exec(sCmdString)

ExecCmdString=oOutExec.StdErr.ReadAll

IfInStr(ExecCmdString,"FAIL")=0andInStr(ExecCmdString,"Exception")=0

Then

ExecCmdString=""

EndIf

SetoOutExec=Nothing

SetoExec=Nothing

EndFunction

41|Dai,HoWu

Appendix3

Samplecodetoopenabrowser(itcheckstoseewhichbrowsertouse):

publicStringopenBrowser(Stringobject,Stringdata,StringconfigPath){APP_LOGS.debug("Openingbrowser");if(CONFIG.getProperty(data).equals("Mozilla"))driver=newFirefoxDriver();elseif(CONFIG.getProperty(data).equals("IE"))driver=newInternetExplorerDriver();elseif(CONFIG.getProperty(data).equals("Chrome"))driver=newChromeDriver();elseif(CONFIG.getProperty(data).equals("Safari"))driver=newSafariDriver();driver.manage().window().maximize();}publicStringclickButton(Stringobject,Stringdata,StringconfigPath){OR=newObjectRepLocator(ObjectRepo);APP_LOGS.debug("ClickingonButton");try{driver.findElement(By.xpath(OR.getLocator(object,configPath))).click();}catch(Exceptione){returnConstants.KEYWORD_FAIL+"Notabletoclickonbutton"+e.getMessage();}returnConstants.KEYWORD_PASS;}

SamplecodetoruntestcasesinGoogleChromeusingtheSeleniumWebDriver:importjava.io.IOException;importorg.openqa.selenium.WebDriver;importorg.openqa.selenium.chrome.ChromeDriver;publicclassChromeTest{/***@paramargs*@throwsInterruptedException*@throwsIOException*/publicstaticvoidmain(String[]args)throwsInterruptedException,IOException{//TellingthesystemwheretofindtheChromedriver

42|Dai,HoWu

System.setProperty("webdriver.chrome.driver","E:/chromedriver_win32/chromedriver.exe");WebDriverwebDriver=newChromeDriver();//Openinggoogle.comwebDriver.navigate().to("http://www.google.com");Stringhtml=webDriver.getPageSource();//Printingresulthere.System.out.println(html);webDriver.close();webDriver.quit();}}

SampleJavacodeimplementingaGooglesearchinSelenium://InitializeaninstanceofWebDriver WebDriverdriver=newHtmlUnitDriver(); //LoadGoogle.com driver.get("https://www.google.com"); //Proceedtoprintthetitle System.out.println("Pagetitle:"+driver.getTitle()); //Enterthesearchwordintothequeryboxandsubmitthesearch WebElementelement=driver.findElement(By.name("q")); element.sendKeys("Test"); element.submit(); //Printthepagetitle System.out.println("Pagetitle:"+driver.getTitle()); //ProceedtoquittheWebDriver driver.quit();

43|Dai,HoWu

Appendix4

ThefindelementbyIDfunctioncanbewrittenineitherway:WebElementUsername=driver.findElement(By.Id(“Username”));//ActioncanbeperformedonInputButtonelementelement.Submit();orBylocator=By.id(“UserName”);WebElementUserName=driver.findElement(locator);BynameThefunctiontogettheelementbynamecanbewrittenas:WebElementelement=driver.findElement(By.name(“firstname”));//ActioncanbeperformedonInputtestelementElement.sendKeys(“ToolsQA”);Thefunctiontogettheelementbyclassnamecanbewrittenas:WebElementparentElement=driver.findElement(By.className(“button”));WebElementchildElement=parentElement.findElement(By.id(“submit”));childElement.submit();Thefunctiontogettheelementbytagname:WebElementparentElement=driver.findElement(By.tagName(“button”));//ActioncanbeperformedonInputButtonelementElement.submit();Thefunctiontogettheelementbylinktextandpartiallinktext:WebElementparentElement=driver.findElement(By.LinkText(“PartialLinkTest”));Element.clear();//OrcanbeidentifiedasWebElementelement=driver.findElement(By.partialLinkText(“Partial”));Element.clear();Thefunctiontogettheelementbyxpath:WebElementUsername=driver.findElement(By.xpath(“ElementXPATHEXPRESSION”));element.Submit();

44|Dai,HoWu

Appendix5

<ObjRep><url>http://www.google.com</url><search_TxtFld>q</search_TxtFld><submt>btnG</submt></ObjRep>Toretrievethisparticularinstance:publicvoidobjRepository(StringeleName){try{Filefile=newFile("F:\\Test.xml");DocumentBuilderFactorydbf=DocumentBuilderFactory.newInstance();DocumentBuilderdb=dbf.newDocumentBuilder();Documentdoc=db.parse(file);doc.getDocumentElement().normalize();//System.out.println("Thenodenameis:"+doc.getDocumentElement().getNodeName());NodeListnList=doc.getElementsByTagName("ObjRep");//System.out.println("Thelengthis:"+nList.getLength());for(inti=0;i<nList.getLength();i++){NodenNode=nList.item(i);if(nNode.getNodeType()==Node.ELEMENT_NODE){Elementele=(Element)nNode;System.out.println(ele.getElementsByTagName(eleName).item(i).getTextContent());}}}catch(Exceptione){e.printStackTrace();}}ToutilizetheObjectRepository:WebDriverd=newFirefoxDriver();d.get(objRepository(url));d.findelement(by.name(objRepository(search_TxtFld)).sendkeys("test");d.findelement(by.name(search_TxtFld(submt)).click();

45|Dai,HoWu

Appendix6

publicclassObjectMap{Propertiesprop;publicObjectMap(StringstrPath){prop=newProperties();try{FileInputStreamfis=newFileInputStream(strPath);prop.load(fis);fis.close();}catch(IOExceptione){System.out.println(e.getMessage());}}TheclasscontainsasinglemethodgetLocator,whichreturnsaByobjectthatisusedbytheSeleniumbrowserdriverobject(suchasaHtmlUnitDriveroraFirefoxDriver):publicBygetLocator(StringstrElement)throwsException{//retrievethespecifiedobjectfromtheobjectlistStringlocator=prop.getProperty(strElement);//extractthelocatortypeandvaluefromtheobjectStringlocatorType=locator.split(":")[0];StringlocatorValue=locator.split(":")[1];//fortestinganddebuggingpurposesSystem.out.println("Retrievingobjectoftype'"+locatorType+"'andvalue'"+locatorValue+"'fromtheobjectmap");//returnainstanceoftheByclassbasedonthetypeofthelocator//thisBycanbeusedbythebrowserobjectintheactualtestif(locatorType.toLowerCase().equals("id"))returnBy.id(locatorValue);elseif(locatorType.toLowerCase().equals("name"))returnBy.name(locatorValue);elseif((locatorType.toLowerCase().equals("classname"))||(locatorType.toLowerCase().equals("class")))returnBy.className(locatorValue);elseif((locatorType.toLowerCase().equals("tagname"))||(locatorType.toLowerCase().equals("tag")))returnBy.className(locatorValue);elseif((locatorType.toLowerCase().equals("linktext"))||(locatorType.toLowerCase().equals("link")))

46|Dai,HoWu

returnBy.linkText(locatorValue);elseif(locatorType.toLowerCase().equals("partiallinktext"))returnBy.partialLinkText(locatorValue);elseif((locatorType.toLowerCase().equals("cssselector"))||(locatorType.toLowerCase().equals("css")))returnBy.cssSelector(locatorValue);elseif(locatorType.toLowerCase().equals("xpath"))returnBy.xpath(locatorValue);elsethrownewException("Unknownlocatortype'"+locatorType+"'");}Gettingtheobjectsfromtheobjectsmap:publicstaticvoidmain(Stringargs[]){//CreateanewinstanceoftheobjectmapObjectMapobjMap=newObjectMap("objectmap.properties");//StartabrowserdriverandnavigatetoGoogleWebDriverdriver=newHtmlUnitDriver();driver.get("http://www.bing.com");//Executeourtesttry{//RetrievesearchtextboxfromobjectmapandtypesearchqueryWebElementelement=driver.findElement(objMap.getLocator("bing.homepage.textbox"));element.sendKeys("AlfaRomeo");//Retrievesearchbuttonfromobjectmapandclickitelement=driver.findElement(objMap.getLocator("bing.homepage.searchbutton"));element.click();//Retrievenumberofsearchresultsusingresultsobjectfromobjectmapelement=driver.findElement(objMap.getLocator("bing.resultspage.results"));System.out.println("Searchresultstring:"+element.getText());//VerifypagetitleAssert.assertEquals(driver.getTitle(),"AlfaRomeo-Bing");

47|Dai,HoWu

}catch(Exceptione){System.out.println("Errorduringtestexecution:\n"+e.toString());}}

48|Dai,HoWu

Appendix7

1)Rightclickon‘x‘packagethenselectNew>Classandnameitas“ProductListing_Page”.

publicclassProductListing_Page{}

2)Createanotherpublicstaticclassinsidetheaboveclass‘x‘andnameitasProduct_1.publicclassProductListing_Page{publicstaticclassProduct_1}}3)NowcreatedifferentStaticMethodsforeachchildelementofProduct_1.ThesemethodswillneedanArgument(WebDriver)andaReturnvalue(WebElement).packagex;importorg.openqa.selenium.WebDriver;importorg.openqa.selenium.WebElement;publicclassProductListing_Page{publicstaticclassProduct_1{publicstaticWebElementtxt_Price(WebDriverdriver){WebElementelement=null;//WriteCodetofindelementherereturnelement;}publicstaticWebElementtxt_SalesPrice(WebDriverdriver){WebElementelement=null;//WriteCodetofindelementherereturnelement;}publicstaticWebElementimg_Product(WebDriverdriver){WebElementelement=null;//WriteCodetofindelementherereturnelement;}publicstaticWebElementtxt_Name(WebDriverdriver){WebElementelement=null;//WriteCodetofindelementherereturnelement;}

49|Dai,HoWu

publicstaticWebElementtxt_Desc(WebDriverdriver){WebElementelement=null;//WriteCodetofindelementherereturnelement;}publicstaticWebElementbtn_AddToCart(WebDriverdriver){WebElementelement=null;//WriteCodetofindelementherereturnelement;}}}ThispieceofcodeforSeleniumissimilartoQTP’sintelligentcodecompletionstructure.

50|Dai,HoWu

Appendix8

AccessingthewebsiteURL:DimURLDimIESetIE=CreateObject("internetexplorer.application")URL="https://www.google.com"IE.Visible=TrueIE.NavigateURLWScript.QuitMainFunctionMainSetIE=WScript.CreateObject("InternetExplorer.Application","IE_")IE.Visible=TrueIE.Navigate"http://google.com"EndFunctionUsingVBStoaccessthewebbygetelementorbyID:DimobjWshShell,IE,searchStrSetobjWshShell=Wscript.CreateObject("Wscript.Shell")SetIE=CreateObject("InternetExplorer.Application")searchStr="test"WithIE.Visible=True.Navigate"http://www.google.com"'WaitforBrowserDoWhile.BusyWScript.Sleep100Loop.document.getElementById("lst-ib").Value=searchStrEndWithobjWshShell.SendKeys"{ENTER}"UsingVBStoloadawebbutton(returnvaluesbyclick):DimobjWshShell,IE,searchStrSetobjWshShell=Wscript.CreateObject("Wscript.Shell")SetIE=CreateObject("InternetExplorer.Application")WithIE.Visible=True.Navigate"https://www.wpi.edu/"

51|Dai,HoWu

'WaitforBrowserDoWhile.BusyWScript.Sleep100Loop.document.getElementById("search-dropdown-button").ClickEndWithUsigVBStoloadawebtable:DimBrowser,strOutSetBrowser=CreateObject("InternetExplorer.Application")WithBrowser.Visible=False.Navigate"http://anees.amoeba.co.in/table.html"'WaitforBrowserDoWhile.BusyWScript.Sleep100LoopEndWithSetdaTable=Browser.Document.getElementById("daTable")strOut=""Fori=0TodaTable.rows.length-1Forj=0TodaTable.rows.item(i).cells.length-1strOut=strOut&daTable.rows.item(i).cells.item(j).innerText&Chr(9)NextstrOut=strOut&Chr(13)&Chr(10)NextBrowser.QuitBrowser=NullMsgbox"TableData:"&Chr(13)&Chr(10)&strOut

52|Dai,HoWu

Appendix9

CodetoconvertobjectrepositoryintoXMLformat:CreatingtheObjectRepositoryUtiltoworkwithORSetobjORU=CreateObject("Mercury.ObjectRepositoryUtil")ExportingtheORintonewXMLfile:objORU.ExportToXML"C:\Users\TestMe.tsr","C:\Users\TestMe.XML"'DestroyingtheobjectSetobjORU=NothinghowtoaddtheobjectbyusingVBScriptSetmyRepository=CreateObject("Mercury.ObjectRepositoryUtil")myRepository.Load"C:\QuickTest\Tests\Flights.tsr"myRepository.AddObjectmyLink,Browser("B").Page("P"),"myLinkName"AnotherwaythatcanbeusedtogettheobjectfromXMLfile,weusethefollowingfunctions:SetobjExcel=GetObject(,"Excel.Application")ForEachobjWorkbookInobjExcel.WorkbooksWScript.EchoobjWorkbook.NameNextObjExcel.QuitNoticethecommabefore'Excel.Application'.ThescriptgetsareferencetoarunningExcelapplication,listsopenworkbooksnamesandquitsExcel.