Concepts in QTP

QTP- QuickTest Professional QTP Testing Process Test Object Model QTP Object Repositories (Covered in Tutorial 21) Descriptive Programming in QTP (Covered in Tutorial 21) CheckPoints in QTP (Tutorial 4-10) QTP Recordings QTP Parameterize Tests QTP Keyword View Actions in QTP

QTP –Quick Test Professional
QTP (QuickTest Professional) is Mercury's advanced keyword-driven testing solution. QTP (provides for functional test and regression test automation. With QTP you will be able to test Standard Windows applications , Web objects, ActiveX controls, and.Net ,Java , SAP (Systeme, Anwendungen und Produkte in der Datenverarbeitung, Systems, Applications and Products in Data Processing) Visual Basic applications. Siebel , Oracle , PeopleSoft and Terminal emulators ( http://www.emtec.com/zoc/terminal-emulator.html) We need additional QuickTest add-ins for special environments e.g. .Net, Terminal emulators. The current version of QTP (version 9.x) supports running tests on the following browsers: Microsoft Internet Explorer 6.0 Service Pack 1 or 7.0 Beta 2 and lower Netscape Browser 8.0 Mozilla FireFox 1.5. QuickTest Professional 9.2 is compatible with: SAP 8.2, .NET 9.2, Web Services 9.2, Java 9.1, Oracle 8.2, PeopleSoft 8.2, Siebel 8.0, Stingray 8.2, Terminal Emulator 8.0, and VisualAge Smalltalk 8.2.

QTP (QuickTest Professional) is Unicode compliant according to the requirements of the Unicode standard, enabling you to test applications in many international languages. As and when an application under test changes, such as when a "Log in" button is renamed "Sign Into," we can make one update to an XML-based Shared Object Repository (within the new Object Repository Manager), and the update will circulate (propagate) to all tests that reference this object. QuickTest Professional keeps object-level changes synchronized among users throughout test creation efforts. Moreover, now users can invoke and run Mercury WinRunner™ scripts and functions from Mercury QuickTest Professional, and then automatically report WinRunner results back into the original scripts.

QTP –Testing Process
QTP (QuickTest Professional) lets you create tests and business components by recording operations as you perform them in your application. Test - A compilation of steps organized into one or more actions, which we can use to verify that our application performs as expected. A test is composed of actions (3 kinds of actions are there in QTP Non-reusable action, Reusable action and External action). First step is Planning Before starting to build a test, you should plan it and prepare the required infrastructure. For example, determine the functionality you want to test, short tests that check specific functions of the application or complete site. Decide how you want to organize your object repositories. Second step in QTP is Creating Tests or Components We can create a test or component by a) Either recording a session on your application or Web site. As we navigate through the application or site, QuickTest graphically displays each step we perform as a row in the Keyword View. The Documentation column of the Keyword View also displays a description of each step in easy-to-understand sentences. A step is something that causes or makes a change in your site or application, such as clicking a link or image, or submitting a data form. OR b) Build an object repository and use these objects to add steps manually in the Keyword View or Expert View. We can then modify your test or component with special testing options and/or with programming statements.

3)Third step is Inserting checkpoints into your test or component. A checkpoint is a verification point that compares a recent value for a specified property with the expected value for that property. This enables you to identify whether the Web site or application is functioning correctly. 4) Fourth step is Broaden the scope of your test or component by replacing fixed values with parameters. To check how your application performs the same operations with different data you can parameterize your test or component. When you parameterize your test or component, QuickTest substitutes the fixed values in your test or component with parameters Each run session that uses a different set of parameterized data is called an iteration. We can also use output values to extract data from our test or component. An output value is a value retrieved during the run session and entered into the Data Table or saved as a variable or a parameter. We can subsequently use this output value as input data in your test or component. We can use many functional testing features of QuickTest to improve your test or component and/or add programming statements to achieve more complex testing goals. 5) Fifth step is running the test After creating test or component, we run it. Run test or component to check the site or application. When we run the test or component, QuickTest connects to your Web site or application and performs each operation in a test or component, checking any text strings, objects, or tables you specified. If we parameterized the test with Data Table parameters, QuickTest repeats the test (or specific actions in your test) for each set of data values we defined. Run the test or component to debug it. We can control the run session to identify and eliminate defects in the test or component. We can use the Step Into ,Step Over And Step Out commands to run a test or component step by step. We can also set breakpoints to pause the test or component at pre-determined points.

A run-time object is the real (actual) object in the application or Web site on which methods are performed during the run session. we can view the results of the run in the Test Results window. or we can report them manually from the Test Results window. If Quality Center is installed. Report defects identified during a run session.We can view the value of variables in the test or component each time it stops at a breakpoint in the Debug Viewer. and that QuickTest executes when the test or component runs. we can view the results. After running the test or component. We can instruct QuickTest to automatically report each failed step in the test or component. Some important points to remember about methods and properties : . View the results in the Results window. Netscape for Netscape objects). Methods of Run-time object are the methods of the object in the application as defined by the object architect (creator). A test object class comprises of a list of properties that can individually (uniquely) identify objects of that class and a set of appropriate methods that QuickTest can record for it. Similarly. Test Object Model Test object Model is a set of object types or Classes that QuickTest uses to represents the objects in our application. we can report the defects fond out to a database. The property set for each run-time object is created and maintained by the object architect (creator) (Microsoft for Internet Explorer objects. We can access and execute run-time object methods using the Object property. We can view a summary of the results as well as a detailed report. Test Object Class A test object is an object that QuickTest creates in the test to correspond to (represent) the actual object in the application. methods of test objects are methods that QuickTest recognizes and records when they are executed (performed) on an object while we are recording. QuickTest uses the stored information about the object during the run session to identify and check the object. 6) Sixth step is analyzing the results After we run test or component. Properties and methods of objects: The property set for each test object is created and maintained by QuickTest.

Properties of test object are captured from object while recording. QuickTest uses the values of these properties to identify runtime objects in the application during a run session. When we run the test. QuickTest executes (performs) the recorded test object method on the run-time object. We can also use regular expressions to identify property values.To make the test object property values match the property values of the run-time object. We can view or modify the test object property values that are stored with the test or component in the Object Properties or Object Repository dialog box. We can retrieve or modify property values of the TEST OBJECT during the run session by adding GetTOProperty and SetTOProperty statements in the Keyword View or Expert View. we can access the internal methods and properties of any run-time object using the Object property.• Each test object method we execute (perform) while recording is recorded as a separate step in the test. There are other . QTP Object Repositories (Covered in Tutorial 21) Descriptive Programming in QTP (Covered in Tutorial 21) CheckPoints in QTP (Covered in Tutorials 4-10) QTP Recordings The default mode of recording is the Normal recording mode. we can modify test object properties manually while designing the test or component or using SetTOProperty statements during a run session. We can view the syntax of the test object methods as well as the run-time methods of any object on our desktop using the Methods tab of the Object Spy. We can also use the attribute object property to identify Web objects in the application according to user-defined properties. Property values of objects in the application may change . • • • • • If the available test object methods or properties for an object are not sufficient or they do not provide the functionality we need. We can retrieve property values of the RUNTIME OBJECT during the run session by adding GetROProperty statements..

QuickTest records all parent level objects as Window test objects and all other objects as WinObject test objects. If the location of the object is important to your test. Analog Recording and Low Level Recording require more disk space than normal recording mode. Use Analog Recording when : The actual movement of the mouse is what you want to record. Low Level Recording: At any time. Exact location of the operation on your application screen is necessary. we can switch to either Analog Recording or Low Level Recording in the middle of a recording session for specific steps and then return to normal recording mode. in normal mode QuickTest performs the step on an object even if it has moved to a new location on the screen. In Analog Recording mode. Recording in Analog mode can be relative to the screen or relative to a specific window (see user guide for detail) In Analog Recording a separate file is saved and stored with the action. as it recognizes the objects in the application regardless of their location on the screen. It records at object level and records all run-time objects as Window or WinObject test objects. Use Low Level Recording when : Environments or objects not supported by QuickTest. if an environment or on an object not recognized by QuickTest. recording a signature produced by dragging the mouse.g. QuickTest adds to your test a RunAnalog statement that calls the recorded analog file. All the three modes of recording can be used in a single test e. Analog Recording : Exact mouse and keyboard operations are recorded in relation to either the screen or the application window. use Low Level Recording.recording modes also like Analog Recording or Low Level Recording. Each step recorded in Low Level Recording mode is shown in the Keyword View and Expert View. Analog Recording steps are not editable from within QuickTest. In this QTP also records and tracks every movement of the mouse for example. Normal mode is the default and takes full advantage of the QuickTest test object model. switch to Low Level Recording QTP Parameterize Tests .

suppose that we want to parameterize a step in Action3 using a value that is passed into the test from the external application that runs (calls) the test. Action parameters enable us to pass values from other actions in your test. Parameterizing the value of a checkpoint property enables us to check how an application or Web site performs the same operation based on different data. These may be values that we supply. Alternatively. all occurrences of the specified object within the action are parameterized. The values of object properties can be parameterized for a selected step. Data Table parameters allow us to create a data-driven test (or action) that runs several times using the data that we supply. We can then use that parameter value to parameterize a step in the test. and that these are all nested actions of Action1. Values in steps and checkpoints and also the values of action parameters can be parameterize. . There are four types of parameters Test/action parameters: Test parameters make possible for us to use values passed from the test. In each repetition. For example. QuickTest uses a different value from the Data Table. We can pass the value from the test level to Action1 (atop-level action) to Action3 (a nested action of Action1). or values that QuickTest generates for us based on conditions and options we choose. For example. the value must be passed down through the action hierarchy of the test to the required action. we are amending the test object description in the local object repository. The values of the operation (method or function arguments) defined for the step can also be parameterized. or iteration. Therefore. We can parameterize a call to Action4 based on an output value retrieved from Action2 or Action3. When the value of an object property for a local object is parameterized. Environment variable parameters allow us to use variable values from other sources during the run session. To use a value within a specific action. greatly increases the power and flexibility of a test. Action3. Values in steps and checkpoints can be parameterized while recording or editing the test. It is known as parameterization. suppose that Action2. A parameter is a variable that is assigned a value from an external data source or generator. Random number parameters Enable us to insert random numbers as values in your test. and then parameterize the required step using this action input parameter value (that was passed through from the external application). and Action4 are sibling actions at the same hierarchical level. Parameters let us check how the application performs the same operations with multiple sets of data.By replacing fixed values with parameters QuickTest enables you to enlarge the scope of a basic test. We can then use these parameters in the action step. we can pass an output action parameter value from an action step to a later sibling action at the same hierarchical level.

Documentation It is a Read-only auto-documentation of what the step does in an easy-to-understand sentence. Value The argument values for the selected operation.QTP Keyword View In QTP we first of all record a test. or statement. QuickTest displays them as steps in the Keyword View. for example. By breaking up the tests into calls to multiple actions. In the keyword view there are 4 visible columns – (For other valuable information on below points please see QTP user guide pg 92 and pg 114) Item The item on which we want to perform the step and it can be a test object. for example. and all objects in its local object repository. and all steps are contained within the relevant branch of the tree. Store in cCols would store the return value of the current step in a variable called cCols so you can use the value later in the test. This column is not visible by default. and then log out of the system (email). the mouse button to use when clicking the image. but before running the test we can also enhance it with checkpoints and parameters. Click the "findFlights" image. This column shows a hierarchical iconbased tree. Actions in QTP Actions break up the test into logical sections/units such as specific activities that we perform in our application. Operation The operation (methods or functions) to be performed on the item selected in the Item column. If you create a test in which you log into the system (email). check inbox. then run a test and then analyze the results. and generates them in a script (in an Expert View). First of all let's talk a little about keyword view in QTP and then we will talk about recording in QTP and then we will move on to other things. This Column is also not visible by default. your test might be structured as shown—one test calling three separate actions: . Comment Any textual information you want to add regarding the step. utility object. When we create a new test. Assignment The assignment of a value to or from a variable for example. it contains a call to one action. An action has its own test script. function call. Click or Select. we can design more modular and well organized and professional tests. An action is stored with the test in which you created it. for example. After recording all the operations. containing all of the steps recorded in that action. The highest level of the tree is actions.

If there is a process that needs to be included in several tests. editable copy of the Data Table information for the external action. It can be called several times by the test with which it is stored (the local test).Test 1 Call to Action 1 Call to Action 2 Call to Action 3 -- -- -- Actions Stored with Test 1 Action1 (Logging in) Action2 (Checking inbox Mails Action 3 (Logging Out) Actions make it possible to parameterize and iterate over specific elements of a test. the test results are divided by actions within each test iteration so that we can see the outcome of each action. For every action called in the test. you should use relative paths for your reusable actions so that other users will be able to open your tests even if they have mapped their network drives differently. modify. Reusable action Reusable actions are like functions in any programming language. we can record. QuickTest creates a corresponding action sheet in the Data Table so that we can enter Data Table parameters that are specific to that action only. If you expect other users to open your tests and all actions in your tests are stored in the same drive. Three types of actions are: Non-reusable action This non reusable action can be called only once and that too in the test with which it is stored. Deleting a reusable action that is called by other tests will cause those tests to fail. as well as by other tests. but we can choose to use a local. new actions are non-reusable. External actions are read-only in the calling test. rather than recording. When we run a test with multiple actions. Then we can call the action from other tests. Each action created in a test can be marked as reusable or non-reusable. the action is inserted in read-only format We can create an additional call to any reusable or external action in the test by pressing CTRL while we drag and drop the action to another location at a parallel (sibling) level within the test. They also make it easier to re-record steps in one action when part of your application changes. When a call to an external action is inserted. By default. and enhance the steps of the process and save them in a reusable action. External action is a reusable action stored with another test. . and enhancing the same steps each time. modifying. and can view the detailed results for each action individually.

. Exist statements always return a Boolean (0 or 1) value. but in case of wait.Wait. we can increase the default timeout settings for a test to instruct QuickTest to allow more time for objects to appear. (Object Synchronization Timeout. File(menu)-> Settings ->Web tab) 4) When working with tests. Wait. Examples where synchronization can be used: For a web page to load. For a button to become enabled or disabled. I will be talking about Sync. WaitProperty-->result of synchronization). File(menu) -> Settings -> Run tab) Synchronization is enabled only during recording. Wait is like forcing the QTP to wait for a specified amount of time while synchronization is not a 'forced' wait e. For client-server communications to finish. Synchronization Synchronization makes available specified amount of time for an object to process prior to moving on to the next step. 2) We can use Exist or Wait statements. Synchronization is possible in many ways: 1) We can insert a synchronization point for example for a progress bar to reach 100%. Example of Synchronization Example of Wait Example of Sync Example of Synchronization Make sure that only QTP and Sample Flight application are open. QTP will generate a WaitProperty statement in the Expert View in case of synchronization.Software Automation Frame work (Covered in other document separately) QTP Sync.g. (Browser Navigation Timeout. Synchronization is there to take care of the timing problems between QTP and the AUT. 3) We can also modify the default amount of time that QTP waits for a Web page to load. whenever a specific page loads QTP moves forward in case of synchronization. if the wait is for 10 seconds and a webpage loads in 3 seconds then it still waits for 7 seconds.

" in the Property value text box." (Don't forget to put those 3 dots.WinEdit("Name:"). Choose Property name as 'text' and Property value as "Insert Done..ActiveX("MaskEdBox"). and double quotation marks e.WinButton("FLIGHT"). In Fly From choose Denver.Click Reservation").Select "Frankfurt" Reservation"). Go to "Windows Applications" tab and choose first option "Record and run test on any open windows based application.H.Select "Denver" Reservation"). Click Stop in order to stop the recording. button which is on the R.' text in the Flight application. Flights Table window open up. Click on Insert Order and let it complete uptill 100% untill you see the 'Insert Done.. QTP will be minimized and cursor will take the shape of a hand..Dialog("Flights Table")." and click on ok.WinComboBox("Fly From:"). Synchronisation Point.' text. 'Add Synchronization Point' window will open..Type "092407" Reservation")..) Click Ok.WinComboBox("Fly To:"). The code in the Expert view looks like this: Window("Flight Window("Flight Window("Flight Window("Flight Window("Flight Window("Flight Window("Flight Window("Flight Reservation").Click Reservation").S of the Fly To combo box.. In Flight application go to File (menu)-> New Order.Click on Record.9 Reservation"). Go to Insert (menu)-&gt.' selected.Synchronization Point' window will open with 'ActiveX: Threed Panel Control. Enter the Date of flight as tommorrows date.Click 1. It will automatically fill some of the fields.. Let the first option remains selected in that and just click on ok. When we click on Record. Enter your name in the Name field.WinButton("Insert Order").ActiveX("MaskEdBox").Set "axc" Reservation").g. "Record and Run Settings" window opens up. In Fly To Choose Frankfurt. ‘Object Selection .WinButton("OK").. Click Ok. This whole process will add WaitProperty. Click on Flights. Click on that 'Insert Done.Click .

Dialog("Flights Table").".Click rc=Window("Flight Reservation").Click 1. 10000) If rc=true Then reporter. "Insert Done. When Flight Reservation window is open..Click I have modified the above script a little bit to capture the WaitProperty value.ActiveX("Threed Panel Control").9 Window("Flight Reservation")..ActiveX("MaskEdBox"). ReportEvent method sends the results to the result window.Select "Denver" Window("Flight Reservation").WinButton("Insert Order"). WaitProperty Waits until the particular object property attain the specified value or exceeds the specified timeout before continuing to the next step.. It will record the code as below but one thing which I have added extra is Wait(5) in step 4 (just go to the expert view and add this line before the line which includes encrypted password).WinButton("Button").WinButton("Button"). Click on Record. For more info on these plase see QTP help.".Type "092407" Window("Flight Reservation").WinEdit("Name:"). Make sure that only QTP should be open.WinButton("FLIGHT").) Enter password as 'mercury.ActiveX("Threed Panel Control"). Go to Start->AllPrograms ->QuickTest Professional ->Sample Applications->Flight. "Insert Done.WaitProperty "text".WinComboBox("Fly From:")." and click on ok. go to File(Menu->Exit.WinComboBox("Fly To:"). Go to "Windows Applications" tab and choose first option "Record and run test on any open windows based application.' Click Ok.. When we click on Record. 10000 Window("Flight Reservation").. Reporter is an Object used for sending info to test results and it uses ReportEvent method to accomplish this. Window("Flight Reservation").. "Property of text is true" End If msgbox rc Window("Flight Reservation"). (use tab to move to password textbox.Click Window("Flight Reservation").Select "Frankfurt" Window("Flight Reservation"). .ReportEvent micPass.WinButton("OK").". Enter Username as your first name (make sure to enter 4 or more characters).Window("Flight Reservation")."sync on Insert Done.Click Window("Flight Reservation"). "Record and Run Settings" window opens up.WaitProperty ("text".Click Example of Wait It is a simple forcible wait.ActiveX("MaskEdBox").Set "axc" Window("Flight Reservation").

It will record the following code with sync automatically recorded by QTP (see 4th step).Press " &File" 7) Browser("Google").WinMenu("ContextMenu").Set "sachin" 3) Dialog("Login"). but here we have set the browser navigation timeout to 2 seconds.Page("Google"). Go to "Web" tab and choose first option "Record and run test on any open browser.Page("Google")."".com as homepage.WinToolbar("ToolbarWindow32").e.com is open (i.EXE".exe".WinEdit("Agent Name:"). after the 3rd step it just waits for 2 second after which it . Web tab and change the 'Browser navigation Timeout' to 2 seconds for example and then run the above code again.WebButton("I'm Feeling Lucky")."C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\".WinEdit("Password:")."C:\Documents and Settings\Sachin".1)SystemUtil. it by default opens google. when you see 'Done' on the status bar at the bottom) .) Type Blogger in the search text box and click on "I'm Feeling Lucky" button instead of Search button.WinMenu("Menu").WinEdit("Agent Name:"). Click on Record."".google.Type micTab 4) wait(5) 5)Dialog("Login").SetSecure "46ed14b628c7ae93e3a3ab35576f08fc424a6fb9" 6) Dialog("Login"). Go toFile(Menu)->Exit. It will fail because sync method waits for the browser to complete the current navigation. "Record and Run Settings" window opens up.Page("Blogger: Create your Blog").com again.Click 7) Window("Flight Reservation").WinButton("OK").com. When www. which is too short for a browser to complete the navigation i.WebEdit("q"). Open internet explorer (make sure your default page is www.blogger."open" 2) Browser("Google"). to open www. so that when you open internet explorer.Select "Close" Try to run this code." and click on ok..Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a. When we click on Record."open” 2) Dialog("Login"). Now go to File(Menu)->Settings.Exit" Example of Sync Make sure that your internet is On and QTP is open. it works fine.Click 4) Browser("Google").Select "File.blogger.Back 6) Browser("Google"). my internet connection is average). 1)SystemUtil\Program files\Internet Explorer\IEXPLORE. click on Back toolbar button (below File menu) to go back to google. because what happens is.Sync 5) Browser("Google").e.Set "blogger" 3) Browser("Google").com after clicking on "I'm Feeling Lucky" button (I am not on T1 lines.

In the Expert View type: a = environment("ActionName") & " is running on " & environment("OS")<br />msgbox (a) 8. Now close this Test Settings window and go to test. Examples of such variables are OS. Keep 'Browser navigation Timeout' to 10 seconds in File(Menu) ->Settings and then it should pass because in 10 seconds it surely makes the back button enabled after the 3rd step of clicking "I'm Feeling Lucky". Built-in variables as the name suggests are predefined by QTP. Built-in are the types of environment variables available in QTP. Lets look at an example of this: 1. . I just did the above four steps in order to show you from where you can access Built-in variables.blogger. And Run the test. 7. Operating System Version and name of the action which is currently running. but it finds it disabled as it gets enabled only when www. 2. 3. 4.Go to File (Menu)->Settings.goes to the Back button. By default Built-in variable type is selected and you will be able to see Name and Description of Built-in variables below Variable type dropdown box. All about QTP Parameters This is not an exhaustive material on parameterization. You can click on any of those variables to see their current value. respectively.com is open. 5. Environment Variables in QTP Random Variables in QTP Test parameters Action Parameter Global and Action data sheet Parameters QTP Output Values Parameterize a checkpoint Environment Variables in QTP User-Defined Internal. a Test Settings window opens. OSVersion. so that you can go ahead and do wonders with parameters in QTP on your own. Go to Environment Tab. Open a new Test. 6. This is just to give you a startup on parameters in QTP. ActionName which are for Operating System. User-Defined External.

Lets look at an example of this: 1. Go to Environment Tab. 2. a Test Settings window opens. Now lets look at an example of this: Open a new text file and type the following lines in it and save it with . User-Defined external variables are the variables which are defined in the file outside of test.) QTP environmental variables 1. Go to File (Menu)->Settings. Now Run the test. I have added quotes just for clarity) and click on OK. Click on "Load variables and values from external file" check box and import that external xml file that we created above. It will add the variable with its type as 'internal'. Open a new Test. in Name type 'a' and in Value type 'hello' (without quotes.g.It is just a simple way to show how a Built-in environment variable works. It will show you the value of variable 'a' in the message box. Go to expert view and type: msgbox(environment("a")) 8. From Variable type dropdown select User-defined. type the name and value of the variable e. Click Apply and OK to come out of Test Settings window. These act as read only for the test. 'Add New Environment Parameter' window opens up. 4. 25 yellow Road under Value and External under Type). As soon as it is imported the complete path of that file will be shown in the File text box and the variable in it will show under Name. ( I saved it in 'tests' folder in the 'QuickTest Professional' folder under C:\Program files. Go to Environment Tab. From Variable type dropdown select User-defined. .xml extension. Open a new Test. Value and Type heading (in our case it will show Address under Name. 6. User Defined Internal variables are the variables defined by you (the user) within the test and which are saved within the test and also accessible from within the test. 5. Go to File (Menu) ->Settings. 4. 7. You can create as many files for environment variables as you want and choose them for your test. 2. Click on the '+' which is on the right of Variable type dropdown. Click on Apply and Ok to come out of it. 3. a Test Settings window opens. 5. 3.

Click ok. select first option For each action iteration. 12. In the keyword View right-click on Action1. Now run the test. 'Action Properties' window opens. Click on Name Checkbox and choose arg_a from the dropdown. 9. select Action Properties. 5. QTP Random Variables First example of Random Numbers: When you define parameters for an action you can set the parameter's value as Random numbers. and Default value as 1. select 'Random Number' from the dropdown. Now Go to Insert (Menu) -> Call to New Action. 2. 10. Click Ok. In the 'Input Parameters' area click on the '+' sign and enter the Name of the input parameter as 'a'. Type as Number. 8. it will become a button '<#>'. Go to 'Parameter Values' Tab. Click on this button. 7. Go to 'Parameters' Tab. In the 'Generate New Random Number' area. Again Click ok to come out of 'Action Call Properties' window. 'Insert Call to New Action' window opens. It will show you the value of variable 'Address' in the message box.6.action2. Lets jump at the examples straightway. 'Action Call Properties' window opens. 6. 11. There are many different ways in which you can use Random numbers in QTP. Click on 'Parameter' radio button. Go to Expert view of action1 and type: Msgbox "action1" Msgbox(parameter("a")) . click ok to insert a new action. Open a new test. Again right-click on Action1 in the keyword View . Example 1: 1. Go to expert view and type: msgbox(environment("Address")) 7. 4. 3. It will open 'Value Configuration Options' window. Make a single click under 'Value' column in the 'Input Parameter's' area. select 'Action Call Properties'. In the Numeric Range enter 0 against From and 100 against To.

1. just click ok. In the 'Input Parameters' area click on the '+' sign and enter the Name of the input parameter as 'a'. If we select the second option 'For each test iteration' then a message box will show same values. Second example of Random Numbers: Here is another way of generating random numbers: Open a new test and in the Expert view write these lines and run the test: For i=1 to 5 var1=RandomNumber (0. and Default value as 1. then it will show you which step it is currently running by pointing to that particular step with yellow color arrow and then you will be able to understand it in a better way. You will see that it shows a different value in each msgbox() because we selected 'For each action iteration' from the 'Generate new random number' area. but different values if you run it next time i. .EndNumber]) EndNumber is optional above. Go to 'Parameters' Tab. select 'Action Properties'.13. RandomNumber("arg_a Next 14. Go to Expert View of Action2 and type: For i=1 to 3 RunAction "Action1".e. 100 Msgbox(var1 Next Third example of Random Numbers: (This is more or less same as the first one) One more way is to define a Random Number parameter in the 'Parameter Options' or 'Value Configuration Options' dialog box. Now Run the test. In the keyword View right-click on Action1. 15. it will show you a message that it has made Action1 Reusable. 'Action Properties' window opens. RandomNumber(ParameterNameOrStartNumber [. Type as Number.) RandomNumber is an Object. 3. Open a new test. a different value at each test run. When you copy the above text to Expert View of Action2. (It would be better if you run it by activating the expert view. Click Ok.oneIteration. 2.

the value returned by the system timer is used as the new seed value. Click on this button. Click ok. No matter how many times you Run the below code it generates the same values: For i= 1 to 3 randomize(2) var1 = Int((6 * Rnd) + 1) ' Generate random value between 1 and 6 MsgBox var1 Next . Now in the Expert View of action1 type: x=RandomNumber("arg_a") Msgbox(x) 12. Click on 'Parameter' radio button. 7. Again Click ok to come out of 'Action Call Properties' window. select 'Action Call Properties'. 11. In the 'Generate New Random Number' area. 10. Make a single click under 'Value' column in the 'Input Parameter's' area. 6. If the number is omitted. select 'Random Number' from the dropdown. the Rnd function (with no arguments) uses the same number as a seed the first time it is called. 'Action Call Properties' window opens.4. It will open 'Value Configuration Options' window. And Run the Test. 9. Again right-click on Action1 in the keyword View . In simple terms Rnd is a function and Randomize is used to initialize this function. Go to 'Parameter Values' Tab. If Randomize is not used. Fourth example of Random Numbers: Another VBScript method of generating a random number: For i= 1 to 3 var1 = int((101*rnd)+0) ' Generate random value between 0 and 100. giving it a new seed value. it will become a button '<#>'. MsgBox var1 Next Let's talk about Randomize and Rnd for some time: Randomize [number] We use a number with Randomize to initialize the Rnd function's random-number generator. 5. select first option For each action iteration . 8. Click on 'Name' Checkbox and choose arg_a from the dropdown. In the Numeric Range enter 0 against From and 100 against To.

For i= 1 to 3 x=rnd() Msgbox(x) Next Remember: For any given initial seed. Before calling Rnd.lowerbound + 1) * Rnd + lowerbound) Likewise Int((6 * Rnd) + 1) ' Generate random value between 1 and 6. use the Randomize statement without an argument to initialize the random-number generator with a seed based on the system timer . For i= 1 to 3 x=rnd(-1) Msgbox(x) Next If the number is Greater than zero(> 0) then Rnd generates 'The next random' number in the sequence. For i= 1 to 3 Randomize var1 = Int((6 * Rnd) + 1) ' Generate random value between 1 and 6 MsgBox var1 Next Some light on Rnd: The following formula is used to produce a random number in a given range: Int((upperbound . the same number sequence is generated because each successive call to the Rnd function uses the previous number as a seed for the next number in the sequence. The Rnd function returns a value less than 1 but greater than or equal to 0. For i= 1 to 3 x=rnd(1) Msgbox(x) Next If the number is Equal to zero (=0)then Rnd generates 'The most recently generated' number.But if you omit randomize(2) from the above code and instead put only randomize then at each run it generates different values. Rnd(number) If the number is Less than zero (< 0) then Rnd generates 'The same number' every time. using number as the seed.

Make a single click under 'Value' heading. This example show how to declare test parameters and how to access those. Enter the Name of the parameter as 'varaction' and its Type as string and no default value. 'Action Properties' window opens. 7. Go to File ->Settings. Go to 'Parameter Values' Tab. Again in the Keyword View right click on Action1 and select 'Action Call Properties'. Enter the Name of the parameter as 'vartest' and its Default Value as 'hello'. Click Apply and then Ok. 5. 10.[ remember this vartest is a test parameter we created at the beginning] 13. it will show a button like this <#>. 'Test Parameters' radio button will be selected by default and under 'Test Parameters' radio button select 'vartest' from Parameter dropdown. you can enter the parameter name in the Expert View using the Parameter utility object. While running it will show 'hello' in the msgbox. 14. Above we have created a Test Parameter 6. go to 'Parameters' Tab. Go to 'Parameters' Tab. 12. Just click on this button to open 'Value Configuration Options' window.Test parameters 1. Go to Expert View and type: msgbox(parameter("varaction")) 15. 9. Click on '+' sign which is on the top right. When you click on ok to come out of 'Value Configuration Options' window. The Type of this parameter is string. 2. Click Ok. a 'Test Settings' window will open. in the 'Action Call Properties' window. Open a New Test. in the format: Parameter ("ParameterName"). Click Ok to come out of that window. 'Action Call Properties' window opens. 8. To use values supplied for test parameters in steps within an action. Now in the Keyword View right click on Action1 and select 'Action Properties'. 3. Click on '+' sign which is on the top right. 4. Remember (taken from QTP guide): You can directly access test parameters only when parameterizing the value of a toplevel action input parameter or when specifying the storage location for a top-level output parameter. Now run the test. Alternatively. you must pass the test parameter to the action containing the step. Click on 'Parameter' radio button and select 'Test/action Parameter' from that dropdown. There you will see the 'varaction' action parameter we created earlier. 11. under 'Value' it will show <vartest>. .

Action Parameter 1. In the Keyword View right click on Action1 and select 'Action Properties'. it will show you the sum 4 in msgbox. 4. Click Ok (make sure we click ok with mouse and not hit the return (enter) Key. Click on '+' sign which is on the top right. In the keyword View right click on action2 and select 'Run from Step'. for each row. in global data sheet. 8. Enter the Name of the parameter as 'a' and its Type as Number. In the Expert View of action2 type: RunAction "Action1". Just click ok to insert a new action. In the Expert View of Action1 type: s1=parameter("a") s2=parameter("b") msgbox(s1+s2) 7. Go to Insert (menu)-&gt. 4. 'Action Properties' window opens. In the Keyword View right click on Action1 and select 'Action Properties'. click on 'Reusable Action' checkbox at the bottom to make the action reusable. 2.) . 'Insert Call to New Action' window opens. 5. Enter the Agent Name as 'mary' and Password as 'mercury'. 3.2 10.Go to Start->All Programs ->QuickTest Professional ->Sample Applications>Flight. 6. Click on Record. 2. oneIteration. 1. Click Ok. 9. Call to New Action. 2. Open a new Test. In the general tab. Go to 'Parameters' Tab. 'Action Properties' window opens. In the same way create another Number parameter 'b'. Make action2 reusable as we did for action1. 3. Global and Action data sheet Parameters Example 1 How. QTP iterates all rows of any action data sheet.

Right click on action1 and select action call properties. 17. It will add a new column in action2 Data Sheet with 'bill ' (because I used bill as an Agent Name ) as its first row. Go to Insert (menu) -> Call to New Action to insert action2. 13.Click • Window("Flight Reservation").5. 11. Click on Parameter radio button and select Data Table from the dropdown and let rest everything be default. Go to Global Data Sheet and Add one more row in it below 'mary'.WinEdit("Password:").Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a. 15.Type micTab • Dialog("Login"). 9."". repeat steps from 2 to 7. 8.Set DataTable("p_Text". click ok to come out of that window. 6. 18. 10. Do the same for action2.WinEdit("Agent Name:").SetSecure "4725bcebeea3b6682d186bf7b15ae92cc4e6c0ba" • msgbox("acton1") • Dialog("Login"). Now my action1 looks like this: • SystemUtil. a button like <#> will appear. go to Run Tab and select "Run on all rows" radio button. make sure you select Current action sheet (local) in the Location in Data Table area. I added 'amar' and 'Sumit'. I added 'rama'.WinButton("OK")."C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\". In the Global Data sheet it will add a new columns with 'mary' as its first value. When the Flight Reservation window is open. After repeating step 7. Now you have two actions (action1 and action2). Go to Expert View of action one and type : msgbox("acton1"). dtGlobalSheet) • Dialog("Login"). For this action2.Select "File. Click Ok to close that window. In the Local Data Sheet (action2) add two more rows to make them a total of 3. Click Stop in order to stop recording the test. when you click on 'Parameter' radio button and select Data Table from the dropdown. 7. go to File ->Exit. (This time I have used the Agent Name as 'bill') 12.Exit" .WinEdit("Agent Name:"). make a single click on 'mary' (Agent Name).exe". click on this button to open 'Value Configuration Options' window."open" • Dialog("Login"). In the Keyword View under 'Value' column. 14. 16.WinMenu("Menu"). both of them do the same job but their data is in different sheets.

1) type 'Action1 Data'. Now Run the test.Value("A". 2) 'accessing data from action1 data sheet from action2 msgbox rc QTP Output Values This is a very small tutorial on output values. Open a new test and also open a sample Flight application (Flight Reservation window) . For complete understanding of Output values please see QTP User Guide. In the Action2 Data table. Open a new test.Value("A".19. Do the same for action2 and type msgbox("acton2") in its Expert view. in cell(A. In the Global Data table. dtGlobalSheet) ‘accessing data from Global data sheet from action1 msgbox rc<br />rc = DataTable.Value("A".1) type 'Action2 Data'. I have added the msgbox step in both the action just to make you understand how the QTP is picking up the rows from Data Sheets.1) type 'Global Data'. otherwise it will be fast and some people may not able to understand. 2) ‘accessing data from action1 data sheet from action1 msgbox rc In expert view of action2 type: msgbox("I am in action 2") rc = DataTable. as we did for action1. In Expert View of action1 type: msgbox("I am in action 1") rc = DataTable. Insert two actions. In the Action1 Data table. dtGlobalSheet) 'accessing data from Global data sheet from action1 msgbox rc rc = DataTable. just to make you familiar with the process so that you can start on your own.Value("A". in cell(A. 1. 20. Example 2 This examples shows that each action can access data not only from Global Data Sheet or its own Local Data Sheet but also from other action's Data Sheet in the same test. in cell(A.

These above steps show you how to use output values with Data Table. "Object Selection .Output Value Properties" window opens with WinButton : Insert Order highlighted. 8. Now earlier where under Value it was showing False (see step 8) now it will show Insert_Order_enabled_Out. Now it means whatever the value of Insert Order button's Enable Property will be. (It creates Insert_Order_enabled_Out column in Global datasheet in Data Table with a Value False in the first row) 11. Click Stop in order to stop the test. . It will show a true value in there at run time. Open a new test and also open a sample Flight application (Flight Reservation window) 2. 5. Click on Record in order to record a test. Go to Insert (Menu) ->Output Value ->Standard Output Value. QTP will be minimized and mouse pointer will take the shape of a hand. Below tutorial shows how to use output values with Environment variables. In this window just click Ok.Make sure that both (new test and Flight Reservation window) are open and visible. It will bring you back to "Output Value Properties" window. In the 'Configure Value' area click on Modify button. Click on Record in order to record a test. 13. 12. Click on 'Insert Order' button in 'Flight Reservation window. 9. 4. 10. 3. "Output Value Properties" window opens with 'Insert Order' in the Name text field. QTP will show that value in Data Table (under Insert_Order_enabled_Out column) at Run time. Again Click Ok to come out of this "Output Value Properties" window. 14. Go to Insert (Menu) ->Output Value ->Standard Output Value. 3. 6. Just make that Insert Order button enable by putting some values in Flight Reservation window and then see that column (Insert_Order_enabled_Out ) in Data table. It will also show that captured value in the Results window. Make sure that both (new test and Flight Reservation window) are open and visible. Click on first checkbox (which is Property enabled and Value False). 4. Click Ok. 1.2. 'Output Options' window opens. 7.

(You can check that environment variable by going to File->Settings. click Record.yahoo.5. Click on first checkbox (which is Property enabled and Value False). msgbox(environment("Insert_Order_enabled_out")) 15.Output Value Properties" window opens with WinButton : Insert Order highlighted.com/ is open and create a standard checkpoint for the Yahoo! ID field. "Output Value Properties" window opens with 'Insert Order' in the Name text field. from 'Output Types' dropdown. Just make that Insert Order button enable by putting some values in Flight Reservation window and then see that environment variable value (Insert_Order_enabled_Out ). In 'Output Options' window. Just add the below line in the Expert View at the end to see the value of the environment variable. 12. In the Configure Value area click on Modify button. and click Ok. 11. 10. 13. Click Ok to come out of this "Output Value Properties" window. Click on 'Insert Order' button in Flight Reservation window. Output Options window opens. 9. Parameterize Checkpoint A checkpoint that uses different expected results for each iteration. You want that only users which are in the data table should be able to login and other could not. A small example: You have certain user names (say 3 in our case) in the data table. 7. Click Ok. Environment Tab and choosing User-Defined from variable type) 14. 8. QTP will be minimized and mouse pointer will take the shape of a hand. It will show a true value in there at run time. It will also show that captured value in the Results window. • While both yahoo mail login and QTP are open. "Object Selection . select Environment. 6. Make sure that http://mail. Now Insert_Order_enabled_out will be User-Defined internal environment variable. . Now you can Run the test.

Check CheckPoint(“login”) Next So the final code looks like this: . Object Selection – Checkpoint Properties window opens.Page(“Yahoo! Mail : The best”). click on Ok.Page("Yahoo! Mail: The best"). The following line will get recorded in QTP Browser("Yahoo! Mail: The best"). Stop recording. Make sure you are in the Expert View. Right click on CheckPoint and select CheckPoint Properties. Checkpoint Properties window opens.WebEdit("login").Page(“Yahoo! Mail : The best”). Click Ok. 5. Add any three names in the first three rows and modify the code as follows: Total=DataTable. Just select the Current action sheet (local) radio button. Check the local data sheet. 9.Seta Browser(“Yahoo! Mail: The best”). 8.Parameter Options window opens. 2.• • • • • Go to Insert->Checkpoint->Standard Checkpoint QTP will be minimized and mouse pointer will take the shape of a hand. 6. 7. Again click Ok to come out of Checkpoint Properties window. Click on the Edit icon on the right side of the Parameter radio button. The first column name must be login_value.WebEdit(login).GetSheet[“Action1”]. click on Ok. Checkpoint Properties window opens.WebEdit(login). Click on the Yahoo! ID text field.SetCurrentRow (i) a=inputbox(“enter value”) Browser(“Yahoo! Mail: The best”). 4.Check CheckPoint("login") 3. Highlight the value property and Select Parameter radio button.GetRowCount Msgbox total For i=1 to total DataTable.

if it is in the data table. Go to Start-> All Programs->QuickTest Professional->Sample Applications->Flight. Enter the Agent Name as "Sachin" and Password as "mercury". Click on Record. Rightclick anywhere on that row and choose "Insert Standard Checkpoint. it will return true. otherwise false Also See: Parameterize a checkpoint for a Flight Application Login Window. When the Flight Reservation window is open Go to File (menu)->Exit. Open a new test. Make sure you use Tab key to move from one text box to another and hit Return (Enter) key after entering the Password. . which you checked above. Make sure only the Text property is checked which has a value of "Sachin" and rest all of the properties must be unchecked. Just make a single click on Text Property. For this tutorial I will take into account Text Checkpoint created through Standard Checkpoint while editing. In the Keyword view go to the row which has "Sachin" under Value column." "Checkpoint Properties" window opens.Now if you run the test it will ask you for each user name you want to enter and compare it with the ones already there in the data table as we have created a check point on it. Click on Stop in order to stop the recording. in order to highlight it and make "Configure Value" area enabled. You can create a Checkpoint while recording or editing a test. Now to see if our checkpoint really works use checkpoint return value (covered in Tutorial 3) to check For every value you enter.

I added "aaaa" in the 2nd and "bbbb" in the 3rd. [On the right hand side of Parameter Radio button you will see Parameter Options button (which has paper and pen image on it). Any value entered there first time will be compared by first row of the Global Data Sheet which has "Sachin" and any value entered there Second time will be compared by second row of the Global Data Sheet which has "aaaa" and so on. Make sure you enter "Sachin" during first time. This is all we need to do. Add two more values in the subsequent rows. Just try to enter some other value during second time like "xxxx" it will run the test but show you "Failed" in the Results window in the second iteration. href property or src property to check whether the image source file is correct or not. e. It will add a column in the Global Data Sheet with "Sachin" as its first value. you can check the map zooms in correctly. you have to enter Agent Name all of the 3 times (Just enter the Agent Name. Insert(menu)->check point->Standard checkpoint Image checkpoints are supported for the web add-in environment only. We don't need to enter the Password. "aaaa" during second time and so on. Using the bitmap checkpoint. Bitmap Checkpoint Bitmap checkpoint lets you check an area of a web page or an application after capturing it as bitmap so that it can compare the expected and the actual bitmap and find out inconsistencies. Remember this is a Text Checkpoint on the "Agent Name" Text field.g As per QTP guide .In this area click on Parameter Radio button. no Tab key or Return key). You can create Bitmap checkpoints for all supported testing environments (As long as the appropriate Add-ins are there) You create an image checkpoint by inserting a standard checkpoint on an image object. suppose you have a website that can display a map of city the user specifies. . There are different properties you can verify like you can check html tag property. you can click on it to see the default values QTP has set for us. Insert(menu)->check point->Bitmap checkpoint or Click the Insert Checkpoint or Output value button and Choose Bitmap checkpoint. You can record the new map that is displayed after one click on the control key that zooms in the map. Now when we run the test and it opens the window where we need to enter the Agent Name and Password. The map has control keys for zooming.] In the "Checkpoint Properties" window just click on Ok to come out of it. Difference Between Image and Bitmap checkpoint Image check Point Image checkpoint lets you check the property value of an image. To create a bitmap checkpoint while recording you go to . that's it.

In the Expert view of Action1 type: s1=parameter("in_a1_1") . In the Parameters tab. Now we have Action1 and Action2 in this test. Rest everything be default. Go to Insert (Menu) -&gt. to add a new action at the end of the test. Call to New Action. it will have Action1. Go to Parameters tab and create input variable in_a1_1 with Type as Number. Action output value (value returned by a called action) can be stored in a variable Action output value (value returned by a called action) can be stored in a variable Open a new test.Action input and Output Parameters Those who are still confused about input parameters to actions and output values from actions. e) Working with Four Actions a). of course there can be other ways of doing the things I have done below). Create another input variable in_a1_2. just have a look at these examples. also create one output variable out_a1_1 with Type as Number (To create an output variable. a) Action output value (value returned by a called action) can be stored in a variable b) Action output value (value returned by a called action) can be stored in data table column. d) Action output value (value returned by a called action) can be stored in Any variable and RunAction Statement is not used. By default. right click on Action1 and choose Action Properties. same as above. you have to click on ‘+’ sign which is on the right hand side of Input parameters section). you have to click on ‘+’ sign which is on the right hand side of Output parameters section). (To create an input variable. c) Action output value (value returned by a called action) can be stored in environment variable. In the Keyword View. these act as a foundation for action input and output values (this is ONE of the many ways.

also create one output variable out_a1_1 with Type as Number (To create an output variable.2. 2. Action output value (value returned by a called action) can be stored in data table column. same as above. Go to Parameters tab and create input variable in_a1_1 with Type as Number. oneIteration. just click on Ok) RunAction "Action1". By default. In the Parameters tab. right click on Action1 and choose Action Properties. you have to click on ‘+’ sign which is on the right hand side of Input parameters section). In the Expert view of Action1 type: s1=parameter("in_a1_1") s2=parameter("in_a1_2 parameter("out_a1_1")=s1+s2 In the Expert view of Action2 type: . Rest everything be default. In the Keyword View. it will have Action1. (To create an input variable. Action output value (value returned by a called action) can be stored in data table column. b). Create another input variable in_a1_2. it may give you a warning that it will make Action1 reusable. to add a new action at the end of the test.s2=parameter("in_a1_2 parameter("out_a1_1")=s1+s2 In the Expert view of Action2 type: (When you copy this below code in Expert view of Action2. var1 msgbox var1 To Run this test make sure Action2 is selected / highlighted if you are in the Keyword View or Action2 is selected from the dropdown above if you are in the Expert View and then choose Automation (Menu) -> Run Current action. Now we have Action1 and Action2 in this test. Go to Insert (Menu) -> Call to New Action. you have to click on ‘+’ sign which is on the right hand side of Output parameters section). Open a new test.

Action output value (value returned by a called action) can be stored in environment variable. 2.dtGlobalSheet) In the Global Data Sheet. DataTable("Action1_out". 2. just click on Ok) RunAction"Action1". It will open Change Parameter Name box. In the Keyword View. Open a new test. in the 'Variable type' dropdown choose Userdefined. By default. right click on Action1 and choose Action Properties. Environment tab. . Now we have Action1 and Action2 in this test. also create one output variable out_a1_1 with Type as Number (To create an output variable. To Run this test make sure Action2 is selected / highlighted if you are in the Keyword View or Action2 is selected from the dropdown above if you are in the Expert View and then choose Automation(Menu) -> Run Current action. double click on A. where you have column names as A. Rest everything be default. In the Parameters tab. Create another input variable in_a1_2. you have to click on ‘+’ sign which is on the right hand side of Input parameters section). B and so on. you have to click on ‘+’ sign which is on the right hand side of Output parameters section). it may give you a warning that it will make Action1 reusable. Go to Insert (Menu) -> Call to New Action. to add a new action at the end of the test. it will have Action1. Go to Parameters tab and create input variable in_a1_1 with Type as Number. Enter the parameter name as Action1_out and click Ok. oneIteration. same as above. c). In the Expert view of Action1 type: s1=parameter("in_a1_1") s2=parameter("in_a1_2") parameter("out_a1_1")=s1+s2 Go to File-> Settings. Click on the + sign which is on the right side. (To create an input variable. Action output value (value returned by a called action) can be stored in environment variable.(When you copy this below code in Expert view of Action2.

2. to add a new action at the end of the test. right click on Action2 and choose Action Properties. Go to Insert-> Call to New Action. In the Keyword View. 2. right click on Action1 and choose Action Call Properties. Open a new test. Go to Parameters tab and in the ‘Store In’ column enter var1. In the Keyword View. Go to Parameters tab and create input variable in_a2_1 with Type as Any. right click on Action2 and choose Action Call Properties. oneIteration. Now we have Action1 and Action2 in this test. it may give you a warning that it will make Action1 reusable. Working with Four Actions. In the Expert view of Action2 type (When you copy this below code in Expert view of Action2. In the Keyword View. Action output value (value returned by a called action) can be stored in Any variable and RunAction Statement is not used. Action output value (value returned by a called action) can be stored in Any variable and RunAction Statement is not used. In the expert view of Action1 type: Parameter("out_a1_1") = 23 In the expert view of Action2 type: msgbox Parameter(" in_a2_1") e). Go to Parameters tab and create output variable out_a1_1 with Type as Any. just click on Ok) RunAction "Action1". In the Keyword View. right click on Action1 and choose Action Properties.‘Add New Environment Parameter’ window opens. Go to Parameters tab and in the Value column enter var1. By default it will have Action1. Enter the Name of the parameter as env_var and let the 'Value' field be empty and click on Ok. . Environment ("env_var msgbox Environment ("env_var") To Run this test make sure Action2 is selected / highlighted if you are in the Keyword View or Action2 is selected from the dropdown above if you are in the Expert View and then choose Automation (Menu) -> Run Current action. d).

Then Action1 passes the sum (i. Automation (Menu) ->Run Current Action What these Actions will do: Action4 will call Action1 with two input values 2. oneIteration.Similarly add 2nd input variable in_a1_2 and one output variable out_a1_1 also a Number Type. oneIteration.5 In the Expert view of Action3 parameter("out_a3_1")= parameter("in_a3_1") + parameter("in_a3_2 . just click on Ok. when ‘Insert Call to New Action’ window opens. 3. always go to Action4 and then. Open a new test. let all other things be default. In the Parameters tab. Obviously Action1 will be there by default. output variable out_a2_1) and Action3 (input variables in_a3_1 & in_a3_2. parameter("out_a1_1"). 2. which is on the right hand side of input parameters. 5. 6. where these passed on values are added and the result is shown in a message box. a1 is for action1 and 1 is 1st variable) and keep its Type as Number. Similarly add input and output parameters for Action2 (input variables in_a2_1 & in_a2_2. Similarly add Action3 and Action4. 1. 3 In the Expert view of Action2 type: parameter("out_a2_1")= parameter("in_a2_1") * parameter("in_a2_2") RunAction "Action3". Go to Insert-> Call to New Action. 4. This adds Action2. 4) along with another number (3) to Action2 by calling Action2 in its last line. In the Keyword View right click on Action1 and choose Action properties. Action1 sums those values (2+2=4) and assigns the sum to out_a1_1 (Action1’s output parameter). Action Properties window opens and go to Parameters tab. Add 1<sup>st</sup> input variable as in_a1_1 ( in means input. Action2 multiplies those two values (4. click on the +.e. parameter("out_a2_1").To Run this test. 3) it got from Action1 and passes on the result of multiplication (12) and another number (5) to Action3. output variable out_a3_1). 2. In the Expert view of Action1 type: s1=parameter("in_a1_1") s2=parameter("in_a1_2") parameter("out_a1_1")=s1+s2 RunAction "Action2".

Click I think for getting the background color it all depends on the kind of objects you are working with because different applications have different objects which in turn have different properties (read both run-time and test). For example: [Open www.Page("Title:=Google"). it will click the "I'm Feeling Lucky" button on the google page.Page("Title:=Google”). 2. WebElement object is a general web object that may represent any web object.com/ Write the below code (either 1 or 2) in the expert view of a new test and run it.bgcolor msgbox Var The first code works only with WebElement objects.WebButton("I'm Feeling Lucky"). It is never recorded.google.Page("Google_2"). Browser("Google").msgbox parameter("out_a3_1") In the Expert view of Action4 type: RunAction "Action1". although we can use Description Programming with WebElement object to perform methods on any web objects in the website.g. "height:=521"). it does not show any property related to color or BackColor in the Test Object Properties radio button. but surely shows a BackColor property in Run-time Object Properties radio button.google.currentstyle.Webelement("name:=I'm Feeling Lucky"). oneIteration. 1) Var=Browser("Title:=Google"). below you can see that when I tried to get the properties for a Label with the help of an Object Spy.com] If you write the below line in the expert view of a new test and Run it. E.webelement("html tag:=body".Page("Google_2").object.Click This same above line can be written using webelement object as: Browser("Google").backgroundcolor msgbox Var OR 2) Var=Browser("Title:=Google").object. So make sure to check for both run-time .2 Capturing Background color in QTP You can use any of the below options to get the background color: Open http://www.

bgcolor or Object. which are all contained within a Browser and Page. Object herirarchy in QTP An interesting point for you to know is (some of you might already be familiar with this) Even though the object on which you record may be embedded in several levels of objects. the recorded hierarchy is only Browser > Page > WebButton .currentstyle. even if the WebButton object on which you record is actually contained in several nested WebTable objects.backcolor.and test properties before going to the conclusion that you cannot get the BackColor of an object.backgroundcolor or object. the recorded hierarchy does not include these objects. I got success with this line: a=SwfWindow(“Teller”).SwfLabel(“window id:=98234”).Object.backcolor Msgbox a So the world does not end at object. just explore it. For example.

For Example (see below image) Object Spy identifies several levels of hierarchy for Submit button. SwfWindow(“Teller”). but while recording (or even when using Descriptive Programming) it just uses the below line of code.SwfButton(“Submit”).Click .

Sign up to vote on this title
UsefulNot useful