166
1) Which environments are supported by QTP? QTP supports the following environments Active X Delphi Java .Net Oracle People Soft Power Builder SAP Siebel Stingray Terminal Emulator Visual Basic Visual Age Web Web Services 2) What are the types object Repositories in QTP. QTP Supports 2 types of Object Repository 1) Shared Object Repository (also called Global) 2) Per-Action Object Repository, (also called Local) Per-Action Object Repository is used by default. The extension for Per-Action repository is ".mtr" . Shared Object Repository is preferable while dealing with dynamic objects which are called in multiple tests. The extension is ".tsr" 3) Can we call QTP test from another test using scripting. Suppose there are 4 tests and I want to call these tests in a main script. Is this possible in QTP? Yes. You can call 4 or even more scripts in your tests.For this, first you will need to make the Actions in the corresponding scripts re-usable.Then from the destination script you can make calls to these re-usable actions. 4) What is action split and the purpose of using this in QTP? Action split is to divide an existing action into two parts.The purpose is to divide actions based on their functionality to improve code re-use. 5) How will you handle Java tree in QTP ? Foremost you will select Java Add - In and launch QTP. Next step record operations on the Java Tree. If you face an issue while recording, you can select Tools > Object Identification > Java, tree object and make changes in mandatory and assistive properties to enable identification. Tip: You can base you answer on similar lines for any other object of any environment. For example : If the question is how will check SAP checkbox , You say , first I will select SAP Add in ... and so on. 6) Explain how QTP identifies object ? QTP identifies any GUI Object based on its corresponding properties. While recording, QTP will identify and store peculiar properties (as defined in the Object Identification settings) in the object repository of the GUI object . At run-time, QTP will compare the stored property values with the on-screen properties, to uniquely identify the GUI object. 7) How many types of recording modes in QTP? Which will be used when ? QTP supports 3 types of recording modes 1. Normal mode also called Contextual 2. Low-level recording mode 3.Analog mode Normal Mode: It is the default recording mode and takes full advantage of QTP's Test Object Model. It recognizes objects regardless of their position on -screen. This is the preferred mode of recoding and is used for most of the automation activities. Low-level recording mode: This mode records the exact x,y co-ordinates of your mouse operations. It is helpful in testing hashmaps. It is useful for recording objects not identified by normal mode of QTP.

QTP Intervieview Question

Embed Size (px)

DESCRIPTION

QTP interview questions asked most of the time in industry

Citation preview

  • 1) Which environments are supported by QTP?QTP supports the following environmentsActive XDelphiJava.NetOracle

    People SoftPower BuilderSAPSiebelStingray

    Terminal EmulatorVisual BasicVisual AgeWebWeb Services

    2) What are the types object Repositories in QTP.QTP Supports 2 types of Object Repository1) Shared Object Repository (also called Global)2) Per-Action Object Repository, (also called Local)Per-Action Object Repository is used by default. The extension for Per-Action repository is ".mtr" .Shared Object Repository is preferable while dealing with dynamic objects which are called in multiple tests. The extension is ".tsr"3) Can we call QTP test from another test using scripting. Suppose there are 4 tests and I want to call these tests in a main script. Is this possible in QTP?Yes. You can call 4 or even more scripts in your tests.For this, first you will need to make the Actions in the corresponding scripts re-usable.Then from the destination script you can make calls to these re-usable actions.4) What is action split and the purpose of using this in QTP?Action split is to divide an existing action into two parts.The purpose is to divide actions based on their functionality to improve code re-use.5) How will you handle Java tree in QTP ?Foremost you will select Java Add - In and launch QTP. Next step record operations on the Java Tree. If you face an issue while recording, you can select Tools > Object Identification > Java, tree object and make changes in mandatory and assistive properties to enable identification.Tip: You can base you answer on similar lines for any other object of any environment. For example : If the question is how will check SAP checkbox , You say , first I will select SAP Add in ... and so on.6) Explain how QTP identifies object ?QTP identifies any GUI Object based on its corresponding properties. While recording, QTP will identify and store peculiar properties (as defined in the Object Identification settings) in the object repository of the GUI object . At run-time, QTP will compare the stored property values with the on-screen properties, to uniquely identify the GUI object.7) How many types of recording modes in QTP? Which will be used when ?QTP supports 3 types of recording modes1. Normal mode also called Contextual

    2. Low-level recording mode3.Analog modeNormal Mode: It is the default recording mode and takes full advantage of QTP's Test Object Model. It recognizes objects regardless of their position on -screen. This is the preferred mode of recoding and is used for most of the automation activities.Low-level recording mode: This mode records the exact x,y co-ordinates of your mouse operations. It is helpful in testing hashmaps. It is useful for recording objects not identified by normal mode of QTP.

  • Analog mode: This mode records exact mouse and keyboard "movements" you perform in relation to the screen / application window. This mode is useful for the operation such as drawing a picture, recording signature., drag and drop operations.8) How will you call from one action to another action ?We can call an action in 2 ways1) Call to copy of Action. - In this ,the Action Object Repository , Script and Datable will be copied to the destination Test Script.2) Call to Existing Action. - In this, Object Repository , Script and Datable will NOT be copied but a call (reference) would be made to the Action in the source script.10) How to perform Cross platform testing and Cross browser testing using QTP? Can u explain giving some example?You will need to create separate Actions which take care of different OS and BrowsersCross Platform Testing:

    Using the Built in Environment Variable you can dig up the OS information.Eg. Platform = Environment("OS"). Then based on the Platform you need to call the actions which you recorded on that particular platform.

    Cross Browser Testing:

    Using this code Eg. Browser("Core Values").GetROProperty("version") you can extract the Browser and its correspondin version. Ex: Internet Explorer 6 or Netscape 5. Based on this value you call the actions which are relevant to that browser.For i=0 To 1If i=0 ThenmyBrowser = "IE"myBrowserpath = "iexplore.exe"ElseIf i=1 ThenmyBrowser = "FF"myBrowserpath = "firefox.exe"

    Set App = CreateObject("QuickTest.Application")App.Visible = TrueApp.Test.Settings.Launchers("Web").Act... = FalseApp.Test.Settings.Launchers("Web").Bro... = myBrowser

    systemutil.Run myBrowserpath ,"http://studyautomation.com"

    If Browser("Study Automation - A Community").Page("Study Automation - A Community").Link("Home").Exist Then

    Reporter.ReportEvent micPass,myBrowser &" Test","Passed"ElseReporter.ReportEvent micFail,myBrowser &" Test","Failed"End IfNext11) What is logical name of the object?Logical name is a name given by QTP while creating an object in the repository to uniquely identify it from other objects in the application. This name would be used by

  • the QTP to map the object name in script with its corresponding description in the object repository. Ex: Browser("Browser").Page("Guru99") Here Guru99 is the logical name of the object.12) What is descriptive programming?Typically ,an object and its properties must be recorded in the Object Repository to enable QTP to perform action s on it.Using descriptive programming , you do not store the object and its property values in the Object repository but mention the property value pair directly in the script.The idea behind descriptive programming is not bypass the object repository but helprecogonize dynamic objects.13)What are the properties you would use for identifying a browser & page when using descriptive programming ?You can use the name propertyex: Browser("name:="xxx"").page("name:="xxxx"").....ORWe can also use the property "micClass".ex: Browser("micClass:=browser").page("micClass:=page")....14)Can we record an application running on a remote machine using QTP ?Yes .you can record remote application provided you are accessing application through the local browser not via remoter like citrix.If you are still unable to record it is advisable install QTP and application, on the same machine15) Explain the keyword CreateObject with an example.Creates and returns a reference to an Automation objectSYNTAX: CreateObject(servername.typename [, location])Argumentsservername: Required. The name of the application providing the object.typename : Required. The type or class of the object to create.location : Optional. The name of the network server where the object is to be created.Example : Set IE = CreateObject("InternetExplorer.Application")16) Can you switch between Per-Action and Shared Object Repository ? If yes how ?Yes .We can switch. Go to Test--->Settings--->Resources. Here you have an option to choose repositories.

    17) What is Object Spy ? How to Use it ?Object Spy helps in determining the run & test time object properties & methods of the application under test.You can access object spy directly from the toolbar or from the Object Repository Dialog Box.It is very useful during Descriptive Programming18) When ordinal identifiers alone can make an object unique then why they are not given top priority? Why it is first mandatory and next assistive. Why we cannot go for ordinal identifiers directly?Consider the following -a) If two objects are overlapped on each other than location based object recognition will fail.b) If only index based recognition is used your script will work but script execution time will increase.Hence mandatory and assistive properties are used.19) What is the file extension of the code file in QTP?Code file extension is script.mts20) Explain in brief about the QTP Automation Object Model.

  • QTP Automation Object model deals with Automation of QTP itself. Almost all configuration and functionality provided by QTP is represented by QTP's Automation Object Model . Almost all dialog boxes in QTP have a corresponding automation object which can set or retrieved using the corresponding properties or methods in the Automation Object Model.QTP Automation Objects can be used along with standard VB programming elements like iterative loops or conditional statements to help you design a script of choice.21) What is the use of Text output value in QTP?Text Output values enable you to capture text appearing on the application under test during run-time.If parameterized, text output values will capture values appearing in each iteration which would be stored in the run-time data table for further analysis.22) What is Step Generator?Step Generator enables use to Add Test Steps in your script. Using step generator you can add steps to your script without actually recording it.23) How to make QTP understand the difference amongst the same type of objects .Suppose there are 5 check boxes in a page and I have to choose the 2nd one, how to do that through script?You can use ordinal identifiers like index along with a little descriptive programming for object recognition.24) What is Test Fusion Report ?.Test Fusion Report , displays all aspects of a test run and is organized in a Tree format.It gives details of each step executed for all iterations.It also gives Run-time data table, Screen shots and movie of the test run if opted.26) What are the types of environment variables in QTP ?Environment variables in QTP are of three types:1) Built-in (Read only)2) User-defined Internal (Read only)3) User-defined External (Read/Write)You Set the Environment Variable using the following syntaxEnvironment.Value( "name") = "Guru99"You can Retrieve the Environment Variable using following syntaxEnvironment.Value("name") -- This will retrun name as Guru99Environment.Value("OS") -- This will return your system OS27) What is the Difference between Bitmap Check point & Image Check point?Bitmap checkpoint does a pixel to pixel comparison of an image or part of an image.Image checkpoint does do a pixel to pixel comparison but instead compare image properties like alt text , destination url etc.28) What is the difference between functions and actions in QTP?Actions have their own Object Repository & Data Table. Actions help make your Test modular and increase reuse. Example: You can divide your script into Actions based on functionality like Login, Logout etc.Functions is a VB Script programming concept and do not have their own Object Repository or Data Table. Functions help in re-use of your code. Ex: You can create a Function in your script to concatenate two strings.29) What is keyword view and Expert view in QTP?Keyword View is an icon based view which shows test steps in tabular format. It also automatically generates documentation for the test steps.

  • Expert View gives the corresponding VB Script statement for every test step in the Keyword view.30) Explain QTP Testing process? -Quick Test testing process consists of 6 main phases:1) Create your test plan - This is preparatory phase where you identify the exact test steps, test data and expected results for you automated test. You also identify the environment and system configurations required to create and run your QTP Tests.2) Recording a session on your application - During this phase , you will execute test steps one by one on your AUT ,and QTP will automatically record corresponding VB script statements for each step performed.3) Enhancing your test - In this stage you will insert checkpoints , output values , parameterization , programming logic like ifelse loops to enhance the logic of your test script.4) Replay & Debug - After enhancements you will replay the script to check whether its working properly and debug if necessary.5) Run your Tests - In this phase you will perform the actual execution of your Test Script.6) Analyzing the test results - Once test run is complete, you will analyze the results in the Test Fusion report generated.7) Reporting defects - Any incidents identified needs to be reported. If you are usingQuality Center , defects can be automatically raised for failed tests in QTP.31) What are the different types of Test Automation Frameworks ?The types of Automation Frameworks are -1) Linear Scripting - Record & Playback2) The Test Library Architecture Framework.3)The Data-Driven Testing Framework.4)The Keyword-Driven or Table-Driven Testing Framework.32) How will you check a web application for broken links using QTP?You can use the Page Checkpoint which gives a count of valid/invalid links on a page.33) What is a Run-Time Data Table? Where can I find and view this table?Data like parameterized output , checkpoint values , output values are stored in the Run-time Table. It is an xls file which is stored in the Test Results Folder. It can also be accessed in the Test Fusion Report.34) What is the difference between check point and output value.Check point is a verification point that compares a current value for a specified property with the expected value for that property. Based on this comparison, it will generate a PASS or FAIL status.An output value is a value captured during the test run and can be stored in a specified location like the Datable or even a variable. Unlike Checkpoints, no PASS/FAIL status is generated.35) How would you connect to database using vbscript ?To connect to the database you must knowa) connection string of your serverb) usernamec) passwordd) DNS nameYou can code the database connectivity command directly or you can use the SQLQuery tool provided by QTP.36) What is QTP batch testing tool?

  • You can use the Batch testing tool to run multiple scripts. Once the scripts are added in the tool , it will automatically open the scripts and start executing them one after the other.37) What are the drawbacks of QTP?As of QTP version 101) Huge Tests in QTP consume lots of memory and increase CPU utilization.2) Since QTP stores results in HTML file (and not txt) the result folder sometimes becomes big.38) What is an Optional Step ?A step when declared optional is not mandatory to be executed. If the corresponding GUI object is present, QTP performs the operation on it. If the GUI object is not present, QTP bypasses the optional step and proceeds to execute the next step.39) What is Reporter.ReportEvent ?Reporter.Reportvent is standard method provided by QTP to send custom messages to the test results window.SyntaxReporter.ReportEvent EventStatus, ReportStepName, Details [, ImageFilePath]where EventStatus = 0 or micPass 1 or micFail 2 or micDone 3 or micWarningResults can assume any status like Pass , Fail , Warning etc. You can also send

    screenshot to the test results window.40) How will you declare a variable in QTP ?You declare using a DIM keyword. You assign value to the variable using the SET keyword.Ex.Dim temp 'Will declare the temp variableSet temp = 20 ' Will assign a value 20 to temp.41) What is GetRoProperty ?GetRoProperty is a standard method provided by QTP to fetch property values of a run

    -time object.42) What is smart Identification?Typically, if even one of the on-screen object property does not match the recorded object property. The test fails.In smart identification, QTP does not give an error if the property values do not match, but uses Base filter and Optional Filter properties to uniquely identify an object. In Smart identification, if a property value does not match the script does not fail but it proceeds ahead to compare the next property. Smart identification can be enabled in Object Identification Dialog box.43) How would you export a Script from one PC to another in QTP ?

    We can make use of the "Generate Script" function available in Object Identification, Test Settings and Tools/Options tab to create a zip of the script at the source computer. These zip files then can be imported into QTP at the destination computer.44) Can launch two instances of QTP on the same machine ?No. You can work with only single instance of QTP on the same machine. But QTP itself can work on multiple instances of the Application Under Test (AUT). Ex: QTP can handle multiple IE browser windows.45) Give the syntax to import/export xls into QTP.

  • DataTable.ImportSheet "..\..\TestData\Input.xls",1,dtGlobalSheetDataTable.ExportSheet "..\..\Results\Output.xls","Global"47) What is the standard timing delay for web based application in QTP ?The standard delay is 60 seconds. This is can be changed in Test Settigns.48) What is the Action Conversion Tool ?It is an in-built tool provided by QTP to convert Actions into Business Process Components.49) What is the extension for a function library ?The extension is '.QFL'50) If the Global Data sheet contains no data and the Local Datasheet contains two rows of data, how many times will the test iterate?The test will iterate only once - global iteration.51) Explain how to read registry key in UFT ?The example demonstrated here explains how to read registry key in UFTCreate a shell objectset MyShell= CreateObject (WScript.Shell)Read the value of key from the registryRegValue =MyShell.RegRead (varpathofkey)in above function we have to pass the path of key in registery.e.g. HKCU\software\ie\settingsmsgbox RegValue52) What are the ways in UFT to get system environment variables in UFT?There are three ways to get system environment variables in UFTUse the WSH shell objectUse WMIs Win32_Environment ClassRead variables from the registrySet myShell = CreateObject (WScript.Shell)WScript.Echo myShell.ExpandEnvironmentStrings( "%PATHEXT%" )

    myShell=Nothing,The output will be .BAT;.CMD;.VBS;. VBE;. JS;. JSEOther user variable, like TEMP, overwrite their system counterpartSet myShell = CreateObject( "WScript.Shell" )WScript.Echo myShell.ExpandEnvironmentStrings( "TEMP=%TEMP%" )myShell=NothingThe output will beTEMP:C:\DOCUME~1\You\LOCALS~1\Temp53) Mention the steps required in UFT to send mail from outlook?To send mail from outlook in UFT,Set Outlook = CreateObject ("Outlook.Application")Dim Message 'As Outlook.MailItemSet Message = Outlook.CreateItem(olMailItem)With Message.Subject = Subject.HTMLBody = TextBody.Recipients.Add (aTo)Const olOriginator = 0.SendEnd With

  • 54) Explain how you can fetch data from database in UFT?To fetch data from database in UFT, you have to follow the code belowSet db= createobject (ADODB.Connection)db.Open Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\guru99\vb6\admission_project.mdb;Persist Security Info= FalseSet rst=createobject(ADODB.Recordset)rst.Open select*from Course, db, 3id=rst. RecordCountFor i=0 to id-1Print rst.field (0) & rst.fields (1) & rst.fields (2) & rst.fields (3)rst.MovenextNext55) What are the codes we can use to get files from ftp server in UFT?To get ftp files from ftp server, you have to use below codea) put- To store single file on serverb) get- To download single file from ftp serverc) mget- To download multiple files from serverd) mput- To store multiple files on servere) delete- To delete files on ftp serverMyShell.Run "%comspec% /c FTP -n -s:" & commandstoworkwithftp & " " & Site, 0,True56) In UFT how you can prevent the system from getting locked?To prevent system getting locked, any of the two ways can be usedCreate a simple vbs file having code to press numlock key and run that vbs fileEdit one registry key DisableLockWorkstation =1 to disable locking57) What is descriptive programming in UFT means?Descriptive programming includes property name and property value. Whenever UFT is facing difficulty in identifying objects from object repository, and instead the object is directly identified from the script is known as descriptive programming.58) In UFT explain the difference between qfl and vbs files?a) qfl is quick test function library file while vbs is Microsofts vbscriptb) qfl is a non-executable file while vbs is an executable filec) To use file in UFT associate qfl file from test setting, while to include vbs file use execute file statement59) What is the code to write data to text file in UFT?To write data to text file in UFT code isContent = Guru99 RocksSet Fo = createobject ("Scripting.FilesystemObject")Set f = Fo.openTextFile ("c:\myFile.txt",8,true) ' open in write modef.Write (contents)f.CloseSet f = nothing60) How to write data to excel file in UFT?Code to write data to excel file in UFT isfilepath = C:\Bugs\Reports.xlsxSet objExcel = CreateObject(Excel.Application)objExcel.Visible= TrueSet Wb= objExcel.Workbooks.Open (filepath)Wb.worksheets(1).Cells(1,1).Value = guru99 read value from Excel file

  • 61) How to create TSR file in UFT?TSR means Test Shared Repository, it is created to share object repository.To create TSR file, follow the stepsOpen object repositoryGo to file menuGo to export local objects option and select itAfter that, UFT will ask you to store .tsr file. Give the path and save. This will create .tsr file in UFT62) How to connect to QC in UFT?To connect with QC, UFT provides the option to connect QC directly from UFT GUI.a) Go to file menub) Select (QC) quality centerc) You will be asked to - Enter QC urld) Enter user id, password and projectFollowing above steps will allow you to connect with QC, later on you can execute the tests from QC itself.64) When we should use descriptive programming in UFT ?Either through object repository or description programming, UFT identifies objects.Descriptive programming is used in following scenariosa) It is used to remove duplicate objects. Same objects exists in different screens or windows of your application. If you use OR in this case you have to store same object under different object hierarchy in OR. To deal with such situation, descriptiveprogramming is usedb) It is not appropriate in certain scenarios to store the objects inside OR (Object Repository). Suppose if you want to print 100 links on the page, you should not store all links in OR. Instead you should use Description Programming to access those links.65) What is settoproperty and when to use it in UFT?Settoproperty stands for set test object property. You can use this property to change the object values at runtime. You can edit the property values during the runtime, but the changes that are made are temporary.66) How to create an array of dictionary in UFT?We can create an array of dictionary using syntaxDim ArrayofDictionary(2)First element of arraySet ArrayofDictionary(0)= createobject("scripting.dictionary")ArrayofDictionary(0).Add "key1", "temp1"ArrayofDictionary(0).Add "key2", "temp2"Added keys in first dictionarySecond element of array as dictionarySet ArrayofDictionary(1)= createobject("scripting.dictionary")ArrayofDictionary(1).Add "key1", "temp1"ArrayofDictionary(1).Add "key2", "temp2"Added keys in second dictionary..and so on67) What is the difference between Array and Dictionary? Array DictionaryDynamic array is possible There is no concept of dynamic dictionarySize of array must be set before the use of array

    The size of dictionary do not need to be set

    We have to use redim statement before To add extra element there is no need to

  • adding extra element into dynamic array write any statement. We just use add method

    There is no particular method to release the memory if particular element is not required

    Element which is not required any longer can be removed from the dictionary

    68) What is round function in UFT?Round function in UFT is used to round the decimalFor exampleMydecimal = 6.3433333Roundedvalue= Round(Mydecimal , 3)Print roundedvalue, it will print 6.34369) How to find the total number of rows in the webtable in UFT?There are three ways which we can find the count of rows in the table in UFTa) Using rowcount property of UFT webtable objectb) Using GetROProperty of UFTc) Using HTML DOM + UFT70) How to create excel file in UFT ?steps will create excel file in UFT,'Create a new Microsoft Excel objectSet myExcel = createobject("excel.application")'To make Excel visiblemyExcel.Application.Visible = truemyExcel.Workbooks.AddMyExcel.worksheets(1).Cells(1,1). Value = Scenario IdMyExcel.worksheets(1).Cells(1,2).Value = Scenario NameMyExcel.worksheets(1).Columns(1).ColumnWidth = 10MyExcel.worksheets(1).Columns(2).ColumnWidth = 40MyExcel.worksheets(1).Columns(3).ColumnWidth = 20MyExcel.worksheets(1).Columns(4).ColumnWidth = 20MyExcel.SaveAs "c:\guru99.xlsx"MyExcel.closeobjExcel.QuitblnFlag = False72) Explain in what ways we can export datatable to excel in UFT?To export data-table to excel, there are two methods.a) DataTable.Export (C:\export.xls)b) DataTable.ExportSheet C:\mysheet.xls ( If excel file does not exist, new file is created)73) In datatable sheet in UFT, how to read a value from the cell?To read a value from the cell, we follow 2 step processa) We set the row pointer in first stepb) In second step we define the parameter/column name from the sheet to readExample:For this example, we have set the row pointer to 2 in transaction sheetDatatable.GetSheet(Transactions).SetCurrentRow(2)Now, we have to specify that we want to read a value from the module_name column from the transaction sheet Print datatable.Value (Module_Name, Transactions)73) What are the loops available in UFT and what they do?There are 3 loops available in UFT

  • a) Do..Loop : Do Loop will run a block of statements repeatedlyb) For..Next : For Next Loop will execute a series of statements until a specific counter valuec) ForEach : In order to execute a series of statements for each statements for each object in collection For Each Loop is usedWhile.Wend Loop : While Wend Loop is used to execute a series of statements as long as given condition is true74) What are the types of error need to be handle in UFT?There are three types of error that one will face in UFTa) Syntax Errorsb) Logical Errorsc) Runtime Errors75) What are the ways you can handle run time errors?There are various ways to handle run time errorsa) Using test settingsb) Using on error statementc) Using err Objectd) Using Exit Statemente) Recovery Scenariosf) Report Object76) What is the difference between exitaction and exititeration?Exitaction is used when we want to exit from a particular action, while exititeration is used to exit from a particular action iteration of an action.77) In QTP how you can remove the spaces from string?You can use replace function to remove spaces from string in QTPPrint replace( sdsd sd sd s , ,)Output will be sdsdsdsdsItrim function can be used if only leading spaces from string needs to be removedPrint Itrim( sdsd sd s ) Output will be sdsd sd sYou can use rtrim function to remove trailing spaces from stringPrint rtrim( sdsd sd s ) Output will be sdsd sd s78) In QTP how you can get the last character from a string?Code to get the last character of a string in QTPprint right( junior,1) Output will be r79) How to add synchronisation points in QTP?There are 4 ways through which we can add synchronisation points in QTPa) Wait statement : This statement will pause the execution for x seconds until object comes upb) Wait property : This method will wait until property of object takes particular valuec) Exist statement : This statement will wait until object becomes availabled) Sync method: The code will wait until browser page is completely loaded. For web application testing this method is used.80) In QTP explain what is crypt objectCrypt object in QTP is used to encrypt a strings.SyntaxCrypt.Encrypt(Guru99)Example :In this example, value in pwd variable is encrypted using the Crypt. Encrypt method.

  • Then this encrypted value is entered into editbox.pwd= myvaluepwd = Crypt.Encrypt (pwd)Browser(myb).WinEdit (pwd). SetSecure pwd81) Mention what is the difference between Excecute file and loadfunction library ?In execute file, we cant debug the statements. With loadfunction library, statements can be debug and can also load multiple library files.82) Explain how you can find length of array in QTP?The code to find the length of array in QTP isprint (ubound(arr)+1)Ubound returns the last index in array- so length of array will be +1. This will be total number of elements in array85) What is Optional step in QTP ? How you can add optional step in QTP?When running a test, it test fails in opening a dialog box, QTP does not necessarily abort the test run. It bye passes any step designated optional and continues running the test. By default QTP automatically marks as optional steps that open certain dialog boxes. In order to set an optional step in the keyword, right click and select Optional Step. The icon for optional step would be added in next step. In the expert view to add optional step, add optional step to the beginning of the VBScript statement.87) How you can write contexts to text file in QTP?Content = Guru99Set Fo = createobject(Scripting.FilesystemObject)Set f =Fo.openTextFile(c:\abc.txt, 8,true)f.Write (contents)f.CloseSet f= nothing88) When option explicit keyword is used in QTP?To specify that all variable must be declared before use in QTP, Option Explicit keyword is used.89) In QTP how you can exit for loop?You must use Exit For statement to exit for loop in QTP. Exit For statement will get the control out of the for loopFor count= 1 to 3TempNum= mid(Tempstr,count,1)If isnumeric(TempNum) ThenLenghtNum = LengthNum & TempNumElseExit ForEnd IfNextGetStrLenNumber = LengthNum91) In QTP, explain what is qrs file?qrs means Quicktest Recovery Scenario. By using recovery scenario manager we can handle exceptions in test execution.In QTP using recovery scenario manager we can handle exceptions in test execution. In QTP when you create a recovery scenario, you must save it in .qrs file. qrs file may have any number of scenarios defined in it.92) What is the significance of action 0 in QTP?Action 0 is created by default when you create a new test in QTP along with action 1.To determine the sequence in which we call other act ions 1,2,3 etc. action 0 is used.

  • 93) Explain how you can replace string in QTP?To replace part of string in QTP we will use the code as shown belowExample,Str = (Guru99)Suppose if you want to replace 99 with 88 then the code willprint replace(str,99, 88) output will be Guru8894) What are the various automation frameworks available in QTP?Various types of automation frameworks available in QTP area) Linear Scriptingb) The Test Library Architecture Frameworkc) The Data Driven Testing Frameworkd) The Keyword Driven or Table Driven Testing Frameworke) The Hybrid Test Automation Framework95) What is Object Spy and what is the function of object spy in QTP?Object Spy is a feature in QTP by using which you can view both the test and run time object properties and methods.96) What is GetROProperty and what are the steps involved in using GetROProperty?GetROProperty is an in built method used to retrieve runtime value of an object property.To use GetRoProperty it involves four stepsa) Record the object on which you want to use the GetROProperty in Object Repositoryb) Identify the run time property for the recorded object which could be usedc) To retrieve the identified run time property and store the value in a variabled) Use this value for further deductions97) Explain how you can find the absolute value of the number in QTP?To find out the absolute value of a number a built in function in QTP is availableExample- a= -1Print abs(a) output will be 1This code will find the absolute value of a number98) How you can check if parameter exists in Datatable?To check whether if parameter exists in data table we will use the codeon error resume nextval=DataTable(ParamName, dtGlobalSheet)if err.number0 thenParameter does not existelseParameter existsend if99) In QTP explain what is keyword driven automation framework? In keyword driven automation framework, the focus is mainly on keywords/functions and not the test data. It means the complete focus is on creating functions which maps the functionality of the application.101) Explain how you can delete excel file in QTP?To delete excel file in QTP,Set fo = createobject(Scripting.filesystemobject)fo.deletefile(C:\xyz.xlsx)Set fo=nothing

    102) What factors affect bitmap checkpoints ?

  • Bitmap checkpoints are affected by screen resolution and image size.103) What is Accessibility Checkpoint?World Wide Web Consortium (W3C) came up with some instructions and guidelines for Web-based technology and information systems to make it easy for the disabled to access the web. For example the standards make it mandatory to have an 'alt text' for an image. So a blind person who is accessing the website, will use text - to -speech converters and atleast understand what the image is about if not see it. All these standards are checked by Accessibility Checkpoints.104) What is .net Spy ?IntroductionDuring software development, a good debugger is invaluable. Likewise, when a runtime exception occurs, .NET's exception information (in particular, the call stack) provides invaluable help. However, sometimes you run into problems where something is not right, and to narrow down the problem, you need to investigate some internal state and data in the application. This is not always easy using the debugger, because there is seldom a natural place to put a breakpoint. It becomes even harder when the application is deployed; the only option is usually if you have left some code in the application to dump the internal state and data in question.The tool Managed Spy and the article about Windows Forms Spy (wfspy) got me hooked on the idea, that it ought to be possible to use reflection to read out public and private members in any running .NET application. The solution presented here does - unlike the others - not stop at the selected control (window); it presents a browsable hierarchy of fields and properties. And unlike Managed Spy, the objects do not have to be serializable; the entire object browser is injected into the address space of the spied application. On the other hand, this solution does not offer any trace features.The SolutionThe solution to the problem described above is implemented as a tool named .NET Object Spy. The main window is small and simple, but easy to use:

    Drag the crosshair to another window, and it will be framed, and the main properties are displayed in the main window. Once released, you get this menu:

  • Select the first option, and the browser is displayed (running in the address space of the selected application):

    You may right-click on a node to bring up a context menu. This allows you to refresh the node (including children).The top line in the window shows the "path" to the currently selected object, e.g. Controls[0].Size.Width. You can also type this in and go directly to the corresponding node. You can even call parameterless methods using this, e.g. Controls[0].GetHashCode() or FindForm().Location.X. The Copy button copies the "path" to the clipboard. The is intended as a help to ObjectSpyEvaluator, which is explained later.The ImplementationThe solution contains three assemblies, which are described in detail in the following paragraphs:InjectLib - A C++ library that wraps the code injection as a generic method, Injector.InvokeRemoteObjectSpy - A C# executable that contains the main windowObjectSpyLib - A C# library that contains the browser, which is injected into the spied applicationInjectLib (InvokeRemote)A spinoff from this solution is a generic method with this signature (C# syntax):Copy Codeobject Injector.InvokeRemote(IntPtr hWnd, string assemblyFile, string typeName, string methodName, object[] args)

  • This wraps the injection process in a generic way that can be used for other purposes. The hWnd parameter identifies the window (and thus the process) in which your code should be injected. The assemblyFile specifies the code that should be injected, typeName specifies a class in this assembly, and methodName specifies a static method on this class. The method is called with the supplied arguments, and may optionally have a return value.There are different methods to inject code into another process (see the CodeProject article Three Ways to Inject Your Code into Another Process). This solution is based on the same approach that most other tools use, Windows hooks (see Using Hooks for details on Windows Hooks). The steps performed by InvokeRemote are:Create a Windows message hook, using the Win32 API function SetWindowsHookExSerialize the parameters to shared memorySend a custom message to the hook, to request its serviceThe hook (i.e., code injected in the target process) now:Deserializes the parameters from shared memoryLoads the requested assemblyInvokes the requested method with the specified parametersSerializes any return value to shared memoryRemove the hookDeserialize the return value from shared memory and return it to the callerSetWindowsHookEx requires the address of the hook function. This must be exported from the library, which cannot be done from C#. Therefore, this library is made as a mixed-mode C++ library, using Visual Studio 2005's C++/CLI support. I.e., the library contains both native and managed code.The memory shared between the two processes is simply a data segment created in the library, i.e., it has a fixed size. For this library, it means that the serialized version of the parameters to InvokeRemote must fit within 2000 bytes (obviously, they must also be serializable). The same limitations apply to the return value. An alternative approach could be memory mapped files (see this article on the MSDN Library).The hook function caused a couple of interesting problems:Problem #1: To make a nice wrapping of the serialization/deserialization, the parameters to the message hook are wrapped in a serializable RequestMessage class, declared in the InjectLib library itself. Despite this, the deserialization in step 4a above failed, complaining that it was unable to find the InjectLib library - obviously ignoring that it was running it in this exact moment! Searching the Internet indicated that this situation may occur if the library is loaded using LoadFrom. Although it is Windows itself that loads the library when it is injected, the suggested solution solved the problem: subscribe to the eventAppDomain.CurrentDomain.AssemblyResolve. This event occurs when the CLR cannot find an assembly, and lets you return the assembly yourself.Problem #2: When the message hook tries to load the assembly specified in the InvokeRemote call (step 4b above), it cannot find it. This is solved by using Assembly.LoadFrom instead of Assembly.Load. The message hook appends the path of InjectLib, assuming that the requested assembly is located in the same place. Otherwise, the requested assembly would have to be placed in the GAC or in the spied application's folder. A solution similar to problem #1 could probably also be used.ObjectSpyObjectSpy is the executable that contains the main window. It is written in C#, and makes several Win32 API calls to find window handles and extract information etc. (for

  • declaring API calls in C#, pinvoke.net is very useful). The implementation of the crosshair approach is highly inspired by the WinSpy demo project in Robert Kuster'sarticle about three ways to inject code into another process. Apart from these API calls, the code is very straightforward, and ends calling InjectLib's InvokeRemote method:Copy CodeInjector.InvokeRemote(hWnd, "ObjectSpyLib.dll", "Bds.ObjectSpy.ObjectSpyForm", "ShowBrowser", new object[] { hWnd });ObjectSpyLibThis C# library contains the browser form which is injected in the spied application. The entry point is the static method specified by ObjectSpy's parameters to InvokeRemote:Copy Codepublic static void ShowBrowser(IntPtr hWnd)This method creates an instance of the form and calls its Show method. The window handle is "converted" into aControl, using Control.FromHandle. The control forms the root of the object hierarchy. From there, the rest is exercising the reflection namespace.Below each node in the tree that represents a non-null object, public and private fields, and properties of that object are added the first time the node is expanded (indexers excluded, since they require parameters). Furthermore, if an object implements IEnumerable, the enumerated objects are added. Whenever a node is selected in the tree, the corresponding object is used as the SelectedObject for the PropertyGrid control in the right side of the window.One thing worth noting is that generic type names are mangled. For example, the typename returned from the reflection classes for the generic List class is "List`1". The number after the backtick indicates the number of type parameters. ObjectSpyLib unmangles this in a recursive manner, and presents it in C# syntax (i.e., using less-than and greater-than characters).ObjectSpyEvaluatorIn addition to the browser form, ObjectSpyLib also includes the class ObjectSpyEvaluator with this static method:Copy Codepublic static string Evaluate(IntPtr hWnd, string expression)The expression parameter is identical to the object "path" that can be entered in the browser. The result of the expression is returned. When performing automated GUI testing, this makes it very easy to write validation code. The validation code might e.g. make a call like this to check the Text property of the root node in a TreeView:Copy Codestring result = (string)Injector.InvokeRemote(hWnd, "ObjectSpyLib.dll", "Bds.ObjectSpy.ObjectSpyEvaluator", "Evaluate", new object[] { hWnd, "treeView.Nodes[0].Text" });A sample application using the Evaluate method - ObjectSpyEE - is included in the downloads:

  • Future EnhancementsI hope this tool is useful as it is (at least it was fun making it!). However, there are several improvements that I would like to do when I have time:Include static membersFind and include "root objects" from the application, if possible (i.e., not just objects referred to by the selected control)Stop expansion when "simple types" (Int32 etc.) are encounteredDisplay private properties + public and private fields in PropertyGrid (by implementingICustomTypeDescriptor)Display additional type information about objects (FullName of declared type, FullName (+Name?) of actual type), possibly in PropertyGridAllow changing the value of "simple types" (Int32 etc.), also when not public properties, and thus in parent's PropertyGridAbort fetching enumerated objects if huge number of objects (when it takes too long)Show information about from which base class a property or field is inherited, possibly in PropertyGridOption to only show fields, not properties, by default (to avoid possible side effects from calling a getaccessor)History2007-02-23 (ObjectSpy 1.2.0)Added ObjectSpyEvaluator, ObjectSpyEE and related functionality in the browser form.2006-12-05 (ObjectSpy 1.1.0)Members are no longer sorted using SortedList (by key), but by Sort method on ordinary List(and implementation of IComparable on ObjectInfo). This solves the problem with handling obfuscated names (like in .NET Reflector). Due to culture issues, keys for different members were considered equal. See Microsft Forums and MSDN for details.Tree in browser window no longer hides selection when there is no focus.Refresh option added in the browser context menu.ObjectInfo has been split up into base and derived classes.Slightly modified icon for browser window (to distinguish it from main window).

  • 2006-11-21 (ObjectSpy 1.0.0)LicenseThis article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)105) What is Array in vbscript?dle this situation.Store all the names in different variablesStore all the names in an arrayIf we follow the first approach,then we will end up mapping each name to variables.This method will be tedious and time consuming task. The second approach of using array is best solution in such situation, where we create an array and store all the names in one variable itself which will reduce the effort in mapping each name with each variable.Array is collection of objects/values in a systematic order.In VBScript ,we can define arrays in two ways:Static Array: It refers to the constant size list in which we cannot add element over its defined capacity.Dynamic Array: Refers to the variable size list in which elements can be added or removed at run time.For Static Array ,the format of declaring the variable is as below :

    1 Dim ArrName(ArrSize)whereArrName=Array NameArrSize =Array Size

    While defining the dynamic array ,we dont need to declare the size of array.

    1 Dim ArrName()whereArrName=Name of an array

    Assigning value to static array in VBScriptThe values that needs to be assigned to the array needs to be on the right hand side of the line

    1 ArrName(ArrIndex)=ValuewhereArrName=Nameofanarray

  • ArrIndex:Location where value needs to be stored.This needs to be an integer value starting from 0 (zero).Assigning value to dynamic array in VBScriptIn dynamic array we use the keyword Redim for redefining the size of an array. As we have seen in Declaring an array, dynamic array doesnt have any size in starting. So we can use Redim for defining the same.

    1 Redim ArrName(ArrSize)whereArrName=NameofanarrayArrSize =Size of the arrayNow, lets take an example, where we have 5 elements (10,20,30,40,50).We need to assign these variables to an array in VB Script.First we need to declare a dynamic array in VbScript for the same.

    1 Dim Arr()Now we need to increase the size of this empty array which can be done using Redim keyword

    1 Redim Arr(5)As we have increased the size of the array as per our requirement,we will now assign the value to this array starting from the position zero(0)

    12345

    Arr(0)="10"...Arr(4)="50"

    So the overall code which has been designed till now looks like

    1 Dim Arr

  • 234567

    Redim Arr(5)Arr(0)="10"Arr(1)="20"Arr(2)="30"Arr(3)="40"Arr(4)="50"

    Lets see the value in the msgbox of the above code till now

    1234

    For i= 0 to 4 FirstArr=FirstArr+"Arr("+cstr(i)+") : "+(Arr(i))&vbnewlinenextmsgbox FirstArr

    The output will be as follows

    12345

    Arr(0) : 10Arr(1) : 20Arr(2) : 30Arr(3) : 40Arr(4) : 50

    Now if we want to add a new element say 60, so again we will redefine the size of array to 6

    12

    ReDim Arr(5)Arr(5)=60

    Now if we check the output again of the array using the code

    1234

    For i= 0 to 5 SecondArr=SecondArr+"Arr("+cstr(i)+") : "+(Arr(i))&vbnewlinenextmsgbox SecondArr

    The output will be as follows

  • 123456

    Arr(0) :Arr(1) :Arr(2) :Arr(3) :Arr(4) :Arr(5): 60

    We see that when we have added an element to an array in Vbscript using Redim keyword,it makes Arr as blank for index 0 to 4.If we want to preserve the values of an array as it is ,we can achieve the same using the Preservekeyword.

    1 Redim Preserve ArrName(ArrSize)whereArrName=Array NameArrsize=Size of an arraySo ,now the code will be as below

    123456789101112

    Dim ArrRedim Arr(5)Arr(0)="10"Arr(1)="20"Arr(2)="30"Arr(3)="40"Arr(4)="50"Redim Preserve Arr(5)For i= 0 to 5SecondArr=SecondArr+"Arr("+cstr(i)+") : "+(Arr(i))&vbnewlinenextmsgbox SecondArr

    The output will be as follows

    Arr(0) :10Arr(1) :20Arr(2) :30

  • Arr(3) :40Arr(4) :50Arr(5): 60

    In this way we can assign the values to the dynamic array.PS: While using array in Vbscript, we recommended the usage of dynamic array instead of the static array as it helps to reduce the memory consumption during execution.108) what is error handling in qtp?Error handling is the way for responding to occurrence of some unexpected situation that arrives during the computation. In automation testing, these unexpected situation can be like objects of application getting changed or some mathematical manipulation etc.For handling such situation Visual Basic Script Edition (VBScript) provides us some of the methods. The details and usage of these methods are as follows:On error resume nextThis statement specifies that when any run time error occurs at particular line in script the control goes to the next line following the statement where the error as occurred.For example: We are performing a division by zero, and if such situation occurs we dont want script to be interrupted. So we will be adding On error resume next statement at the top of the script.On error resume nextDivision=100/0If Div=0 thenMsgbox PassElseMsgbox FailEnd ifOn error go to 0Disables any enabled error handler and reset it to nothingErr objectErr object is the intrinsic object with global scope means there is no need to create the instance of it for accessing the various methods of it.The details of all the methods of err object can be find in the below table:Err Properties Details

    NumberReturns the integer value telling the type of the error occurred

    DescriptionGives the reason for the occurrence of the error

    Source

    HelpFile

    HelpContext

    Err Methos Details

    ClearHelps to reset the error handler to nothing

    once the error has been handled.

    Raise

  • Lets take the example of division by zero again.

    'Call the division functioncall divisionFunction division()on error resume next'divide by zeroz=100/0' Report the error occured. You can see the error number and description in msgboxIf Err.number 0 thenMsgbox Error Number + Err.NumberMsgbox Error Description + Err.Description'disables error handlingon error goto 0End ifEnd functionIn Visual Basic, we have two more methods available for error handlingOn Error Goto Line Moves the control to a particular line number.On Error Goto Label Moves the control to a particular section of code which is defined in a label.These two methods are not available in VBScript.109) What is Virtual Objects?When Nothing Works Virtual Objects is the weapon to achieve your goal. Many of the times you will find that QTP is not able to recognize an object, even if the object behaves like a standard object. Virtual objects helps in such situation, to be able to identify and run tests.Virtual object feature in QTP enables us to create and run tests on objects that are not normally recognized by QTP. we can define such objects as virtual objects and map them to standard classes like button, checkbox etc.QuickTest emulates the actions on virtual object during the run session. A virtual object can be defined using the virtual Object Wizard. The wizard prompts you to select the standard object class to which you want to map the virtual object. You then mark the boundaries of the virtual object using a crosshairs pointer. Next, you select a test object as the parent of the virtual object. Finally, you specify a name and a collection for the virtual object. A virtual object collection is a group of virtual objects that is stored in the Virtual Object Manager under a descriptive name. Virrtual Object Manager feature enables us to create and manage virtual objects.Virtual Object WizardLaunch Virtual Object Wizard by selecting Tools > Virtual Objects > New Virtual ObjectSelect Next at Welcome screen

  • figure 1 : Virtual Object Wizard Welcome screenSelect the class which most resembles your virtual object.

    figure 2 : Map to a Standard ClassClick on Mark object button and mark the area in application (around the object you want to create virtual)Click Next

    figure 3 : Mark Virtual ObjectSelect one of the following optionsEntire Parent hierarchy if you want to add the whole hierarchy.Parent only if you want to add only the parent.Click Next

  • figure 4 : Object ConfigurationSpecify the desired object name and the collection name.Click Finish.

    figure 5 : Save Virtual ObjectVirtual Object ManagerSelect Tools > Virtual Objects > Virtual Object Manager to open Virtual Object Manager.Virtual object manager list all of available virtual object collections. We can delete the virtual object from virtual object collections.

    figure 6 : Virtual Object Manager

  • To disable recognition of virtual objects while recording select Tools > Options and click General tab, and select the Disable recognition of virtual objects while recording check box.

    Object Spy cannot be used on virtual objectsScroll bars and Labels cannot be treated as Virtual objectsQTP does not support virtual objects for analog or low level recording.If you have used virtual objects and that too only after doing a record, and you are wondering if we have descriptive programming for virtual objects as well! The answer to these is Yes, we do have and we can easily do the same for Virtual Objects. For those who are not aware of what Virtual Objects are, let us first understand what it is and how it works. Virtual object feature in QTP enables us to create and run tests on objects that are not normally recognized by QTP. These objects can be any object that behave like standard objects but are not recognized by QTP. Virtual objects helps a lot in such situations.Recently, I encountered a similar situation where I had to click on a link which was there in the email body (I will elaborate the whole scenario in a seperate post). Although the link was behaving properly it was not getting recognized by QTP, actually QTP was identifying the whole body section as an object. objective was to open the url which was associated with the link and that was getting opened only after clicking the link at the email body. I tried other means but no luck. So finally in this situation Virtual Object was very helpful and it worked like a charm.So, we can define such objects as virtual objects and map them to standard classes like button, checkbox etc. QuickTest emulates the actions on virtual object during the run session. A virtual object can be defined using the virtual Object Wizard(Tools>Virtual Objects>New Virtual Object). The wizard prompts you to select the standard object class to which you want to map the virtual object. You then mark the boundaries of the virtual object using a cross-hair pointer. Next, you select a test object as the parent of the virtual object. Finally, you specify a name and a collection for the virtual object. A virtual object collection is a group of virtual objects that is stored in the Virtual Object Manager under a descriptive name. Find more details on virtual objects step by step with screenshots in my earlier post Virtual Objects When Nothing works.The virtual objects that you create using the virtual object wizard, gets stored as VOT file into \ dat \ VoTemplate. That means, if you want to use the script in which you have added the virtual object onto some other machine then this VOT file also needs to be copied to the same location on the other machineswherever you want the script to execute. This is main challenge for maintaining the script and the execution on multiple machines or in other terms portability. To overcome this issue, Descriptive programming is the best way. Basically a virtual object stores and uses the properties x,y,width and height with it. so if by any means we are able to maintain these properties and values then we are done. below is an example of how we can do it

    1 Browser("Google").Page("Google").VirtualButton("x:=667","y:=158","height:=21","width:=75","name:=Saket").Click

  • This way we can run the script without having the virtual object collection or the VOT files on the machine.We can do the same with using description object as well.

    12345

    Set oVDesc=Description.CreateoVDesc("x").value=667oVDesc("y").value=158 oVDesc("height").value=18 oVDesc("width").value=41 Browser("name:=Google").Page("title:=Google").VirtualButton(oVDesc).click

    Descriptive programming for virtual objects can be done only for the classes which can be created using the virtual object manager.for virtual lists objects use one more property rows:=row numberfor tables use rows:=row number and columns:=column number

    110) What is Dictionary object ?Most of the time; We use variables, when we need to store a input value or a value retrieved from an outside source. When there are many such values, either we use individual variables or we can store in an array. Alternatively, information can also be stored in a Dictionary object. It is a part of VB Script and so it can be used with the tools supporting VBS.The Dictionary object is used to hold a set of data values in the form of (key, item) pairs. A dictionary is sometimes called an associative array because it associates a key with an item. The keys behave in a way similar to indices in an array, except that array indices are numeric and keys are arbitrary strings. Each key in a single Dictionary object must be unique.A Dictionary object can contain any data including objects and other Dictionary objects. The value of these dictionary items can be accessed by using unique keys that are stored along with the data, rather than by using an items ordinal position as you do with an array. This makes the Dictionary object ideal when you need to access data that is associated with a unique named value.

    Adding Keys and ItemsDictionary is a COM objects, it can be instantiated in the same way as any other COM Object. TheProgID for a Dictionary object is Scripting.Dictionary, and so the following example creates a Dictionary object using CreateObject:

    12

    Dim oDictSet oDict = CreateObject("Scripting.Dictionary")

    One you have created an instance of the Dictionary object, you can use the Add method to add items to the dictionary. The Add method requires two parameters, which must be supplied in the following order and separated by a comma.for example

  • Key Value

    Book1 QTP Unplugged

    Book2 QTP DP Unplugged

    Book3 UFT & QTP Interview UnpluggedDictionary keys must be unique. In the examples below, after the first line is interpreted, the key Book1 will already be in the Dictionary.

    1234

    Set oDict = CreateObject("Scripting.Dictionary")oDict.Add "Book1", "QTP Unplugged"oDict.Add "Book2", "QTP DP Unplugged"oDict.Add "Book3", "UFT & QTP Interview Unplugged"

    To retrieve the value from dictionary created, we can use .item method of dictionary object.

    1 oDict.item("Book2")

    One potential problem in using the Dictionary object is that any attempt to reference an element that is not contained in the Dictionary does not result in an error. Instead, the non-existent element is added to the Dictionary. Consider the following script sample, which creates a Dictionary, adds three key-item pairs to the Dictionary, and then attempts to echo the value of a non-existent item, Book4:

    12345

    Set oDict = CreateObject("Scripting.Dictionary")oDict.Add "Book1", "QTP Unplugged"oDict.Add "Book2", "QTP DP Unplugged"oDict.Add "Book3", "UFT & QTP Interview Unplugged"MsgBox oDict.Item("Book4")

    When the script tries to output the value of the nonexistent item, no run-time error occurs. Instead, the new key, Book4, is added to the Dictionary, along with the item value Null.To avoid this problem, check for the existence of a key before trying to access the value of the item. you can do so using .exists method.

  • 12345

    Set oDict = CreateObject("Scripting.Dictionary")oDict.Add "Book1", "QTP Unplugged"oDict.Add "Book2", "QTP DP Unplugged"oDict.Add "Book3", "UFT & QTP Interview Unplugged"if oDict.Exists("Book4") then msgbox oDict.Item("Book4")

    Looping through the Items in Dictionary ObjectEach item stored in a Dictionary object can be accessed by using For Each statements as shown in the snippet below

    1234567891011121314151617

    Dim oItemDim sItem, sMsgDim oDict

    Set oDict = CreateObject("Scripting.Dictionary")

    Set oDict = CreateObject("Scripting.Dictionary")oDict.Add "Book1", "QTP Unplugged"oDict.Add "Book2", "QTP DP Unplugged"oDict.Add "Book3", "UFT & QTP Interview Unplugged"

    For Each oItem In oDict sItem = oDict.Item(oItem ) sMsg = sMsg & sItem & vbCrLfNext

    MsgBox sMsg

    Configuring Dictionary PropertiesThe Dictionary object has only one configurable property, Compare Mode, which plays an important role in determining which keys can be added and which ones cannot.By default, a Dictionary is created in binary mode, which means each key in the Dictionary is based on its ASCII value. This is important because the ASCII value of an uppercase letter is different from the ASCII value of that same lowercase letter. In binary mode, both of these services can be added to the Dictionary as individual keys. So we can have same keys for multiple Items when in binary mode. for example, book and BOOKWhen a Dictionary is configured in text mode, uppercase and lowercase letters are treated identically.To configure the Dictionary mode, create an instance of the Dictionary object and then set the CompareMode property to one of the following values:

  • 0 Sets the mode to binary. This is the default value. 1 Sets the mode to text.

    12

    Set oDict = CreateObject("Scripting.Dictionary")oDict.CompareMode = 1

    You cannot change the CompareMode property of a Dictionary if that Dictionary contains any elements. This is because the binary mode allows you to differentiate between keys based solely on uppercase and lowercase letters. In text mode, however, these three keys are considered identical. If you had these elements in a binary Dictionary and were able to reconfigure that Dictionary in text mode, the Dictionary would suddenly contain three duplicate keys, and it would fail. If you must reconfigure the Dictionary mode, you first need to remove all items from the Dictionary.

    Manipulating Keys and Items in a DictionaryBy itself, a Dictionary is of little use; a Dictionary is valuable only when you can access, enumerate, and modify the keys and items within that Dictionary. After you have created a Dictionary, you will probably want to do such things as: Determine how many key-item pairs are in that Dictionary. Enumerate the keys and/or items within the Dictionary. Determine whether or not a specific key exists in the Dictionary. Modify the value of a key or an item in the Dictionary. Remove key-item pairs from the Dictionary.To remove a value from a dictionary, use the .Remove method and specify the key to remove. For example:oDict.Remove Book2To remove all values and clear the dictionary, use the .RemoveAll method. Use the .Count property to obtain a count of values in the dictionary.The .Keys and .Items methods return an array containing all the keys or items from the dictionary. For example:

    12

    aBooks = oDict.KeysaNames = oDict.Items

    Enumerating a DictionaryItems and Keys method returns the array of Items and keys respectively. These methods cannot be directly used to access the values, there return array has to be first assigned to a variable and then accessed. Below example illustrates the enumerations.

  • 1234567891011121314151617181920

    'Create the dictionary objectSet oDict = CreateObject("Scripting.Dictionary")oDict.Add "Book1", "QTP Unplugged"oDict.Add "Book2", "QTP DP Unplugged"oDict.Add "Book3", "UFT & QTP Interview Unplugged"

    aItems = oDict.Items

    'Print all the items in the dictionaryFor i = LBound(aItems) To UBound(aItems) Print aItems(i)Next

    'Print all keys in the dictionary'We can use For each loop also to access the arrayaKeys = oDict.KeysFor Each Key in aKeys Print "Key - " & Key Print "Value - " & oDict(Key)Next

    Use of Dictionary ObjectsGenerally dictionaries are used when items need to be stored and recovered by name. For example, a dictionary can hold all the environment variables defined by the system or you have some configuration values for the script which you want to be accessed through out your script scope.Here is niceA very simple answer for when should we use dictionary object? would be use dictionary object, when you need find value by keyAs Reserved Object in QTP/UFTYou can add dictionary as a reserved object in QTP/UFT , follow the steps belowOpen registry editor through windows run window (type regedit)Browse to HKEY_CURRENT_USER\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjectsCreate a new key under this key with Name as Dictionary and as String value ProgID with data as Scripting.Dictionary as shown in below snapshot.

  • Start QTP, type Dictionary., it should show the methods and properties of dictionary objects to use.

    Sorting a DictionaryBelow function demonstrate, how we can sort a dictionary with items. [Source]

    1234567891011121314151617181920

    Const dictKey = 1Const dictItem = 2

    Function SortDictionary(objDict,intSort) ' declare our variables Dim strDict() Dim objKey Dim strKey,strItem Dim X,Y,Z

    ' get the dictionary count Z = objDict.Count

    ' we need more than one item to warrant sorting If Z > 1 Then ' create an array to store dictionary information ReDim strDict(Z,2) X = 0 ' populate the string array For Each objKey In objDict strDict(X,dictKey) = CStr(objKey) strDict(X,dictItem) = CStr(objDict(objKey)) X = X + 1 Next

    ' perform a a shell sort of the string array For X = 0 to (Z - 2) For Y = X to (Z - 1) If StrComp(strDict(X,intSort),strDict(Y,intSort),vbTextCompare) > 0 Then strKey = strDict(X,dictKey) strItem = strDict(X,dictItem)

  • 2122232425262728293031323334353637383940414243444

    strDict(X,dictKey) = strDict(Y,dictKey) strDict(X,dictItem) = strDict(Y,dictItem) strDict(Y,dictKey) = strKey strDict(Y,dictItem) = strItem End If Next Next

    ' erase the contents of the dictionary object objDict.RemoveAll

    ' repopulate the dictionary with the sorted information For X = 0 to (Z - 1) objDict.Add strDict(X,dictKey), strDict(X,dictItem) Next

    End If

    End Function

    111) What are Object models in qtp ?An Object Model is basically the way we use the object properties in a Programming language or technology. When we say usage of object properties, it means accessing the objects by object references to achieve the objectives like invoking a particular method of object. For example, object model of MS Excel, which enables other program to control it via different methods and properties.A collection of objects or classes through which a program can examine and manipulate some specific parts of its world. In otherwords, the object-oriented interface to someservice or system. Such an interface is said to be the object model of the represented service or system.

    In this post we will discuss about the four different types of Object ModelsTest Object Model ( TOM )Document Object Model ( DOM )Component Object Model ( COM )Automation Object Model ( AOM )

    Test Object Model ( TOM )A collection of object types or classes which represents the different objects in theapplication. For Example a button object or edit box object in an application are the objects of and represent Button class or Edit box class. These test object class has a several properties to uniquely identify the objects of the particular class and methods to perform specific actions.There are two types of objects in TOM,Test Object andRun-time object.The objects which QuickTest creates and stores to represent the object in application, is a test object whereas a run-time object is the actual object in the application on which methods are performed during the run session, i.e the test object object

  • 54647484950

    properties are the properties as they are saved in the test object repository. Run time properties refers to the object properties as it appears in thefor example, a button with one of the properties repository, which can be enable/disable at run time depending on certain conditions.with this we can understand that the test object properties doesapplication to open and can be modified whereas a runthe application to be open and it cannot be modified.If you have ever wondered about thenow you know that RO is for Runretrieve the value of the object at run time. TO is for Test Object and so the value of an object in object repository can be modified using

    Document Object Model ( DOM )Web Pages are organized into different objects like document,properties and methods available for the objects. These objects can be accessed by using scripts for the web pages. The Document Object Model is an interface(API) which allow programs and scripts to access and update thestyle of documents. This is not only applicable for web pages (HTML) but for XML as well.The objects in the document are in a hierarchy. DOM helps QTP to ahierarchy of a web pagedirectly by scripting. To access themethod for the specific web object.For example, you can use DOMan object. Consider the part of page

    123

    Google SearchI'm Feeling Lucky

    the part of the source is for the two buttons at Google search page.

    If you need to click on the Google Search button using DOM, you will have to look into the source. For the button there are certain properties like id, name etc,in the source above. These properties can be used to identify the object and do the action. If we take the Name property, this can be used byas below

    properties are the properties as they are saved in the test object repository. Run time properties refers to the object properties as it appears in the application under test.for example, a button with one of the properties enable is true in the object repository, which can be enable/disable at run time depending on certain conditions.with this we can understand that the test object properties does not require your application to open and can be modified whereas a run-time object property requires the application to be open and it cannot be modified.If you have ever wondered about the RO in GetROProperty and TO in SetTOProperty

    O is for Run-time Object and so GetROProperty is used to retrieve the value of the object at run time. TO is for Test Object and so the value of an object in object repository can be modified usingSetTOProperty.

    Document Object Model ( DOM )e organized into different objects like document, tables etc using the

    properties and methods available for the objects. These objects can be accessed by using scripts for the web pages. The Document Object Model is an interface(API) which allow programs and scripts to access and update the content, structure and style of documents. This is not only applicable for web pages (HTML) but for XML as

    The objects in the document are in a hierarchy. DOM helps QTP to access this directly by scripting. To access the DOM we use .

    method for the specific web object.DOM to identify an object when QTP is not able to identify

    an object. Consider the part of page source below for Google search page.

    b>label="Google Search" name=btnK class=gbqfba>Google Searchlabel="I'm Feeling Lucky" name=btnI class=gbqfba

    onclick="if(this.form.q.value)this.checked=1;else on='/doodles/'">I'm Feeling

    Luckythe part of the source is for the two buttons at Google search page.

    If you need to click on the Google Search button using DOM, you will have to look into button there are certain properties like id, name etc, you can find

    in the source above. These properties can be used to identify the object and do the action. If we take the Name property, this can be used byGetElementsbyName

    properties are the properties as they are saved in the test object repository. Run time application under test.

    is true in the object repository, which can be enable/disable at run time depending on certain conditions.

    not require your time object property requires

    SetTOProperty, is used to

    retrieve the value of the object at run time. TO is for Test Object and so the value of

    etc using the properties and methods available for the objects. These objects can be accessed by using scripts for the web pages. The Document Object Model is an interface(API)

    , structure and style of documents. This is not only applicable for web pages (HTML) but for XML as

    ccess this we use .object

    identify an object when QTP is not able to identify below for Google search page.

    label="Google Search" name=btnK class=gbqfba>

  • 1 Browser("Google").Page("Google").object.getElementsByName("btnK").Item(0).clickYou can use GetElementsbyTagName to have all the button objects and then search for the required one as below

    123456789101112

    Set PageObject = Browser("Google").Page("Google").objectset ButtonObjects=PageObject.getElementsByTagName("button")

    For each button in ButtonObjects

    If lcase(button.type)="button" Or lcase(button.type)="submit" Then If UCase(button.name)="BTNK" Then

    button.click Exit For

    End if End If

    NextI am listing here some important properties and methods that you can use in QTPGetElementById Method returns a list of objects with specified id. If the id for the objects are not unique it take the first object with the specified value of the ID attribute.

    12345678910

    Set PageObject = Browser("Google").Page("Google").objectSet InputObjects = PageObject.getElementsByTagName("INPUT")

    inCount=InputObjects.Length-1For i=0 to inCount If InputObjects(i).Name="q" and InputObjects(i).Type="text" Then PageObject.getElementsByName(InputObjects(i).Name)(0).Value="Automated-360" Exit For End IfNext

    ElementFromPoint Method returns the object at specific coordinate on the page. for example the below code finds the search text box as per x and y coordinate and sets the value.

  • 123

    x=Browser("name:=Google").Page("title:=Google").WebEdit("name:=q").GetROProperty("x")y=Browser("name:=Google").Page("title:=Google").WebEdit("name:=q").GetROProperty("y")Browser("name:=Google").Page("title:=Google").Object.elementFromPoint(x,y).Value="Automated-360"

    Some useful Properties which can be used for different purposesactiveElement Retrieves the object that has the focus when the parent document has focus. Get the name of the text box which has the focus during runtime

    1 Print Browser("Google").Page("Google").Object.activeElement.name

    cookie Sets or retrieves the string value of a cookie. Find more details on Cookie here

    1 Print Browser("Google").Page("Google").Object.Cookie

    documentElement - Retrieves the root node of the document.

    1 Print Browser("Google").Page("Google").Object.documentElement.innerHTML

    readyState - Retrieves a value that indicates the current state of the object. This property can be used for sync in QTP scripts.

    1 Browser("Google").Page("Google").Object.readyState

    Component Object Model ( COM )It is used to enable interprocess communication and dynamic object creation in a large

  • range of programming languages. COM is the basis for several other Microsoft technologies and frameworks, including OLE, OLE Automation, ActiveX, COM+, DCOM, the Windows shell, DirectX, and Windows Runtime.COM is basically used by developers to make the things simpler and easier to build and link by creating reusable components. The objects can be accessed by the interface (properties and methods) provided by COM for a particular class. Basically the properties and methods of an object can be the interface of the object and accessed by taking the reference of the object.COM objects can be used with any tool that supports COM automation. And since VBScript supports COM automation, It becomes very easy to use in QTP scripting. But we cannot use all the COM objects, we can use only those objects that expose a string called a programmatic identifier (ProgID). Although not all COM objects have a ProgID, all COM objects have a 128-bit number called a classidentifier, or CLSID. If a COM object has a ProgID, you can use VBScript to instantiate the object, invoke its methods and properties, and destroy the object.To use a COM object in a script, you must first create an instance of the object. You can do this by calling the CreateObject or GetObject method.

    1 Set oFSO = CreateObject("Scripting.FileSystemObject")CreateObject creates an Automation object of the specified class. If the application is already running, it creates a new instance. Set statement creates the reference between the object variable and the object. once the work is done the object reference should be destroyed as below

    1 Set oFSO = NothingYou can also use GetObject method which returns a reference to an instance of an object. It can be used in two way with its parameters, the objects pathname and the objects ProgID.

    1 Set oWord = GetObject("C:\Test\Test1.doc")or

    1 Set oWord = GetObject("","Word.Application")

  • Automation Object Model ( AOM )An Object Model is a structural representation of objects that comprise the implementation of a system or application. Automation enables software packages to expose their unique features to scripting tools and other applications. Usually Automation uses the Component Object Model (COM). A critical aspect of COM is, how client and servers interact. A COM server is any object that provides services to clients; these services are in the form of COM interface implementations like Properties, Methods, Events and their relationships. Which can be called by any client that is able to get a pointer to one of the interfaces on the server object.QuickTest Professional is also a COM Server and its different methods and properties are exposed by its COM interface which can be accessed by other applications and scripting tools to control it from outside. In this post, we will see how to interact with QTP from outside via Automation Object Model.Find more detail in the post Automation Object Model : QuickTest Professional . It is same for UFT as well without any changes. Below code snippet illustrates the launch of UFT.

    1234567

    Dim UFTApp

    Set UFTApp= CreateObject("QuickTest.Application") ' Create the application object

    UFTApp.Launch 'Start QuickTest

    UFTApp.Visible = True ' Make it visible

    112) How To generate Random strings in QTP/UFT?'************************************'Logic Explanation:'************************************' RandomNumber ststement only gives specific random numbers between given range' 97-122 are the ASCII codes for a-z alphabets.' Chr(97) will return 'a', Similarly Chr function return chacters based on ASCII codes' In below function the random numbers will be generated between 97-122' Using Chr function the generated numbers will be converted in to characters' The generated characters will store in "gChr" variable' Finally gChr value will be returned as Function Value'************************************Function GenerateRandomString(StrLength)' Declare VariablesDim StrLenIndexDim chrAscCodeDim gChr

    'Use for loop to generate StrLength many characters

  • For StrLenIndex = 1 To StrLength ' Get Random ASCII Code chrAscCode=RandomNumber(97,122) ' Convert ASCII code in to character gChr=gChr&Chr(chrAscCode)Next'Return converted character to functionGenerateRandomString=gChr

    End Function'************************************'Function Calling'************************************MsgBox GenerateRandomString(5)'************************************113) Closing of Browsers all browsers Except Qc/ALM Except Last Browser Except First Browser?

    '##################################'Close All browsers'##################################'Method 1'***************************************************'Call FunctionCall CloseAllBrowsers("IE")

    '***************************************************'Logic Explanation'SystemUtil.Closeprocessbyname closes specific process by nameFunction CloseAllBrowsers(oBrName)' Close the specific/all browsersSelect Case ucase(oBrName)

    Case "IE" 'Close IE SystemUtil.CloseProcessByName "iexplore.exe" Case "FF" 'Close FF SystemUtil.CloseProcessByName "firefox.exe" Case "CHROME" 'Close CHROME SystemUtil.CloseProcessByName "chrome.exe" Case "ALL" 'Close All Browsers SystemUtil.CloseProcessByName "iexplore.exe" SystemUtil.CloseProcessByName "firefox.exe" SystemUtil.CloseProcessByName "chrome.exe"

    End Select

  • End Function'***************************************************'Method 2'***************************************************'Logic Explanation'Desktop is a built in object'ChildObjects is a method to get child objects based on description provided in description object'When we give "Micclass" as browser in description object, all browsers in desktop will be returned'We for loop from "0" to Count-1 because the Object Indexing starts from "0"'We will close each and every browser with for loop and index

    Function CloseAllBrowsers() 'Declare VariablesDim oBrDesDim oBrObjListDim objIndex

    'Create Description Object with Browser classSet oBrDes=Description.CreateoBrDes.Add "micclass","Browser"

    'Get Browser Objects from DesktopSet oBrObjList=Desktop.ChildObjects(oBrDes)

    'Use For Loop to close each browser'Use Count-1 because Object Indexing starts from "0"For objIndex=0 to oBrObjList.count-1

    'Close the Browser oBrObjList(objIndex).closeNext

    'Release VariablesSet oBrObjList=NothingSet oBrDes=Nothing

    End Function

    '##################################'Close All browsers except Alm/Qc'##################################'Logic Explanation'Desktop is a built in object'ChildObjects is a method to get child objects based on description provided in description object'When we give "Micclass" as browser in description object, all browsers in desktop will be returned'We will check the the title before closing every browser with for loop and index

  • 'We for loop from "0" to Count-1 because the Object Indexing starts from "0"'If title is "Quality Center" or "ALM" we will not close itFunction CloseAllBrowsersExceptQC()'Declare VariablesDim oBrDesDim oBrObjListDim objIndex

    'Create Description Object with Browser classSet oBrDes=Description.CreateoBrDes.Add "micclass","Browser"

    'Get Browser Objects from DesktopSet oBrObjList=Desktop.ChildObjects(oBrDes)

    'Use For Loop to close each browser'Use Count-1 because Object Indexing starts from "0"For objIndex=0 to oBrObjList.count-1

    'Verify the name of the browser is "Quality Center" or "ALM" If lcase(oBrObjList(objIndex).GetROproperty("name"))"mercury quality center" then 'Close the Browser oBrObjList(objIndex).close Exit For End IfNext

    'Release VariablesSet oBrObjList=NothingSet oBrDes=Nothing

    End Function

    '##################################'Close All browsers except last opened browser'##################################'Logic Explanation'Desktop is a built in object'ChildObjects is a method to get child objects based on description provided in description object'When we give "Micclass" as browser in description object, all browsers in desktop will be returned'We for loop from "1" to Count-1 because the in this script we will not work with object indexing'We will get the count of number of browsers and write a FOR loop with Count-1 times 'because we should close all browsers except one'Each time we have to verify "0" creationtime browser exist and if exist close it'We will repeat this Count-1 times'The For Loop gets exit when the last browser creationtime becomes "0"

  • Function CloseAllBrowsersExceptLastBrowser()

    'Declare VariablesDim oBrDesDim oBrObjListDim iCounter

    'Create Description Object with Browser classSet oBrDes=Description.CreateoBrDes.Add "micclass","Browser"

    'Get Browser Objects from DesktopSet oBrObjList=Desktop.ChildObjects(oBrDes)

    'Use For Loop to close each browser'Use Count-1 because we should close all browsers except oneFor iCounter=1 to oBrObjList.count-1

    'Close the first browser each time by checking creationtime "0" If Browser("creationtime:=0").Exist Then 'Close Browser oBrObjList("creationtime:=0").close End IfNext

    'Release VariablesSet oBrObjList=NothingSet oBrDes=Nothing

    End Function

    '##################################'Close All browsers except First opened browser'##################################'Logic Explanation'Desktop is a built in object'ChildObjects is a method to get child objects based on description provided in description object'When we give "Micclass" as browser in description object, all browsers in desktop will be returned'We for loop from "1" to Count-1 because the in this script we will not work with object indexing'We will get the count of number of browsers and write a FOR loop with Count-1 times 'because we should close all browsers except one'Each time we have to verify "1" creationtime browser exist and if exist close it'We will repeat this Count-1 times'The For Loop gets exit when there no extra browsers

    Function CloseAllBrowsersExceptLastBrowser()

  • 'Declare VariablesDim oBrDesDim oBrObjListDim iCounter

    'Create Description Object with Browser classSet oBrDes=Description.CreateoBrDes.Add "micclass","Browser"

    ' Get Browser Objects from DesktopSet oBrObjList=Desktop.ChildObjects(oBrDes)

    'Use For Loop to close each browser'Use Count-1 because we should close all browsers except oneFor iCounter=1 to oBrObjList.count-1

    'Close the second browser each time by checking creationtime "1" If Browser("creationtime:=1").Exist Then 'Close Browser oBrObjList("creationtime:=1").close End IfNext

    'Release VariablesSet oBrObjList=NothingSet oBrDes=Nothing

    End Function

    114) Prepare QTP/UFT for Test Batch Execution Using AOM?'***************************************************'***************************************************'Author - QtpSudhakar.com'Purpose - To Run a Test Batch for all tests in side of a folder' - This will create a CSV file which will have all the status of execution'How to Use - Specify the Folder Path of where tests are stored' - Make sure you don't have any other empty folders without QTP test' - Give TestPath, Save the code into VBS file and Double click on vbs file'***************************************************'For any doubts contact https://www.facebook.com/Qtpsudhakarblog'***************************************************'***************************************************'Declare VariablesDim TestsFolderPath 'To specify Tests folder pathDim QtApp 'To store Qtp Automation ObjectDim fso 'To access file systemDim fld 'To store the test folder objectDim tFlName 'Unique File name to store Test ResultsDim fl 'To store Result File ObjectDim fldLst 'To store Child Folders(tests) of base folderDim f 'To store each QTP Test Folder

  • Dim tPath 'To store QTP Test PathDim tName 'To Store QTP Test NameDim WSH 'To open the created CSV result file

    'Specify Base Tests Folder PathTestsFolderPath="C:\Users\sudhakar\Desktop\tests"

    'Create QTP Automation ObjectSet QtApp = CreateObject("QuickTest.Application")QtApp.launch 'open QTPQtApp.visible=True 'Make it visible

    'Create File system objectSet fso = CreateObject("scripting.filesystemobject")

    'Get the base Tests folderSet fld=fso.GetFolder(TestsFolderPath)

    'Generate a unique file name with date and timetFlName="TestExecution_"&Replace(replace(replace(now,"/","_"),":","_")," ","_")&".csv"

    'Create the CSV file with the created nameSet fl=fld.CreateTextFile(tFlName)

    'Get Subfolders from main folderSet fldLst=fld.SubFolders

    'Write first row as columns in CSV filefl.WriteLine "TestName,TestPath,Status"

    'Get each folder path and name to execute the testFor Each f In fldLsttPath=f.Path 'Get Test PathtName=f.Name 'Get Test NameQtApp.open tPath 'Open Test in QTPQtApp.test.run 'Execute Test

    'Write Test result status into CSV filefl.WriteLine tName&","&tPath&","&QtApp.test.LastRunResults.status

    Next

    'Close CSV filefl.Close

    'Get CSV File PathtStatusFilePath=TestsFolderPath&"\"&tFlName

    'Create WSH object to open the CSV fileset wsh=CreateObject("wscript.shell")

  • wsh.Run tStatusFilePath 'Open CSV file

    'Release VariablesSet WSH=NothingSet f=NothingSet fldLst=NothingSet fl=NothingSet fld=NothingSet fso=NothingSet QtApp=Nothing

    115) Defaults method and common verification in QTP/UFT?

    Object ClassDefault Operation Common Verifications

    Window Activate Exist, TitleDialog Activate Exist, TitleWinObject Click Exist, TextWinRadioButton Set Exist, Default Selection

    WinTab SelectExist, Default Selection, Items Count, Item Existence

    Browser Sync ExistPage Sync ExistImage Click Exis