Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
QTP Recordings
Actions in QTP
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 (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).
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.
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
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.
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.
After running the test or component, we can view the results of the run in the Test
Results window. We can view a summary of the results as well as a detailed report.
If Quality Center is installed, we can report the defects fond out to a database. We
can instruct QuickTest to automatically report each failed step in the test or
component, or we can report them manually from the Test Results window.
Test object Model is a set of object types or Classes that QuickTest uses to
represents the objects in our application.
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.
A run-time object is the real (actual) object in the application or Web site on which
methods are performed during the run session.
The property set for each test object is created and maintained by QuickTest. The
property set for each run-time object is created and maintained by the object
architect (creator) (Microsoft for Internet Explorer objects, Netscape for Netscape
objects).
Similarly, methods of test objects are methods that QuickTest recognizes and
records when they are executed (performed) on an object while we are recording,
and that QuickTest executes when the test or component runs. Methods of Run-time
object are the methods of the object in the application as defined by the object
architect (creator). We can access and execute run-time object methods using the
Object property.
• 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.
• Property values of objects in the application may change .To make the test
object property values match the property values of the run-time object, we
can modify test object properties manually while designing the test or
component or using SetTOProperty statements during a run session. We can
also use regular expressions to identify property values.
• 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 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 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 retrieve property values of the
RUNTIME OBJECT during the run session by adding GetROProperty
statements..
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 access the internal methods
and properties of any run-time object using the Object property. We can also use
the attribute object property to identify Web objects in the application according to
user-defined properties.
CheckPoints in QTP
QTP Recordings
The default mode of recording is the Normal recording mode. There are other
recording modes also like Analog Recording or Low Level Recording. Normal
mode is the default and takes full advantage of the QuickTest test object model, as
it recognizes the objects in the application regardless of their location on the screen.
Analog Recording : Exact mouse and keyboard operations are recorded in relation
to either the screen or the application window. In this QTP also records and tracks
every movement of the mouse for example, recording a signature produced by
dragging the mouse. Analog Recording steps are not editable from within
QuickTest.
Each step recorded in Low Level Recording mode is shown in the Keyword View
and Expert View.
All the three modes of recording can be used in a single test e.g. 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.
Analog Recording and Low Level Recording require more disk space than
normal recording mode.
In Analog Recording a separate file is saved and stored with the action.
If the location of the object is important to your test, switch to Low Level
Recording
Parameters let us check how the application performs the same operations with
multiple sets of data.
Data Table parameters allow us to create a data-driven test (or action) that runs
several times using the data that we supply. In each repetition, or iteration,
QuickTest uses a different value from the Data Table.
Values in steps and checkpoints can be parameterized while recording or editing the
test.
The values of the operation (method or function arguments) defined for the step can
also be parameterized.
When the value of an object property for a local object is parameterized, we are
amending the test object description in the local object repository. Therefore, all
occurrences of the specified object within the action are parameterized.
In QTP we first of all record a test, then run a test and then analyze the results, but
before running the test we can also enhance it with checkpoints and parameters.
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.
After recording all the operations, QuickTest displays them as steps in the Keyword
View, and generates them in a script (in an Expert View).
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,
utility object, function call, or statement. This column shows a hierarchical icon-
based tree. The highest level of the tree is actions, and all steps are contained within
the relevant branch of the tree.
Value The argument values for the selected operation, for example, the mouse
button to use when clicking the image.
Comment Any textual information you want to add regarding the step. This Column
is also not visible by default.
Actions in QTP
Actions break up the test into logical sections/units such as specific activities that
we perform in our application.
When we create a new test, it contains a call to one action. By breaking up the
tests into calls to multiple actions, we can design more modular and well organized
and professional tests. An action has its own test script, containing all of the steps
recorded in that action, and all objects in its local object repository. An action is
stored with the test in which you created it.
If you create a test in which you log into the system (email), check inbox, and then
log out of the system (email), your test might be structured as shown—one test
calling three separate actions:
Test 1 Actions Stored with
Test 1
Call to Action 1 -- Action1 (Logging in)
Call to Action 2 -- Action2 (Checking inbox
Mails
Call to Action 3 -- Action 3 (Logging Out)
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.
External action is a reusable action stored with another test. External actions are
read-only in the calling test, but we can choose to use a local, editable copy of the
Data Table information for the external action. When a call to an external action is
inserted, 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.
By default, new actions are non-reusable. Each action created in a test can be
marked as reusable or non-reusable.
When we run a test with multiple actions, the test results are divided by actions
within each test iteration so that we can see the outcome of each action, and can
view the detailed results for each action individually.
If you expect other users to open your tests and all actions in your tests are stored
in the same drive, 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.
Software Automation Frame work
Wait is like forcing the QTP to wait for a specified amount of time while
synchronization is not a 'forced' wait e.g. whenever a specific page loads QTP moves
forward in case of synchronization, but in case of wait, if the wait is for 10 seconds
and a webpage loads in 3 seconds then it still waits for 7 seconds.
Synchronization is there to take care of the timing problems between QTP and the
AUT. Examples where synchronization can be used:
1) We can insert a synchronization point for example for a progress bar to reach
100%. QTP will generate a WaitProperty statement in the Expert View in case of
synchronization.
2) We can use Exist or Wait statements. Exist statements always return a Boolean (0
or 1) value.
3) We can also modify the default amount of time that QTP waits for a Web page to
load.
(Browser Navigation Timeout, File(menu)-> Settings ->Web tab)
4) When working with tests, 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 -> Run tab)
Example of Synchronization
Example of Wait
Example of Sync
Example of Synchronization
Make sure that only QTP and Sample Flight application are open.
Click on Record. When we click on Record, "Record and Run Settings" window opens
up. Go to "Windows Applications" tab and choose first option "Record and run test on
any open windows based application." and click on ok.
Click on Insert Order and let it complete uptill 100% untill you see the 'Insert
Done...' text.
‘Object Selection - Synchronization Point' window will open with 'ActiveX: Threed
Panel Control.' selected.
Click Ok.
'Add Synchronization Point' window will open. Choose Property name as 'text' and
Property value as "Insert Done..." (Don't forget to put those 3 dots, and double
quotation marks e.g. " in the Property value text box.)
Click Ok.
Reporter is an Object used for sending info to test results and it uses ReportEvent
method to accomplish this.
ReportEvent method sends the results to the result window. For more info on these
plase see QTP help.
If rc=true Then
reporter.ReportEvent micPass,"sync on Insert Done...", "Property of text is true"
End If
msgbox rc
Window("Flight Reservation").WinButton("Button").Click
Example of Wait
Click on Record. When we click on Record, "Record and Run Settings" window opens
up. Go to "Windows Applications" tab and choose first option "Record and run test on
any open windows based application." and click on ok.
Enter Username as your first name (make sure to enter 4 or more characters).
(use tab to move to password textbox.)
Enter password as 'mercury.'
Click Ok.
When Flight Reservation window is open, go to File(Menu->Exit.
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).
1)SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest
Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury
Interactive\QuickTest Professional\samples\flight\app\","open”
Example of Sync
Make sure that your internet is On and QTP is open.
Click on Record. When we click on Record, "Record and Run Settings" window opens
up. Go to "Web" tab and choose first option "Record and run test on any open
browser." and click on ok.
Open internet explorer (make sure your default page is www.google.com, so that
when you open internet explorer, it by default opens google.com as homepage..)
Type Blogger in the search text box and click on "I'm Feeling Lucky" button instead
of Search button.
When www.blogger.com is open (i.e. when you see 'Done' on the status bar at the
bottom) , click on Back toolbar button (below File menu) to go back to google.com
again.
Go toFile(Menu)->Exit.
It will record the following code with sync automatically recorded by QTP (see 4th
step).
Built-in variables as the name suggests are predefined by QTP. Examples of such
variables are OS, OSVersion, ActionName which are for Operating System, Operating
System Version and name of the action which is currently running, respectively.
3. Go to Environment Tab. 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.
4. You can click on any of those variables to see their current value.
5. I just did the above four steps in order to show you from where you can access
Built-in variables.
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. 'Add New Environment Parameter' window opens up, type the name and value of
the variable e.g. in Name type 'a' and in Value type 'hello' (without quotes, I have
added quotes just for clarity) and click on OK. It will add the variable with its type as
'internal'.
8. Now Run the test. It will show you the value of variable 'a' in the message box.
User-Defined external variables are the variables which are defined in the file
outside of test. These act as read only for the test. You can create as many files for
environment variables as you want and choose them for your test.
Open a new text file and type the following lines in it and save it with .xml extension.
( I saved it in 'tests' folder in the 'QuickTest Professional' folder under C:\Program
files.)
4. Click on "Load variables and values from external file" check box and import that
external xml file that we created above. 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, Value and Type heading (in our case it will show Address under Name, 25
yellow Road under Value and External under Type).
7. Now run the test. It will show you the value of variable 'Address' in the message
box.
When you define parameters for an action you can set the parameter's value as
Random numbers. There are many different ways in which you can use Random
numbers in QTP. Lets jump at the examples straightway.
Example 1:
3. In the 'Input Parameters' area click on the '+' sign and enter the Name of the
input parameter as 'a', Type as Number, and Default value as 1. Click Ok.
4. Again right-click on Action1 in the keyword View , select 'Action Call Properties',
'Action Call Properties' window opens. Go to 'Parameter Values' Tab.
5. Make a single click under 'Value' column in the 'Input Parameter's' area, it will
become a button '<#>'. Click on this button.
7. Click on 'Parameter' radio button, select 'Random Number' from the dropdown. In
the Numeric Range enter 0 against From and 100 against To.
9. In the 'Generate New Random Number' area, select first option For each action
iteration. Click ok.
11. Now Go to Insert (Menu) -> Call to New Action, 'Insert Call to New Action'
window opens, click ok to insert a new action- action2.
Msgbox "action1"
Msgbox(parameter("a"))
13. Go to Expert View of Action2 and type:
For i=1 to 3
RunAction "Action1",oneIteration, RandomNumber("arg_a
Next
14. When you copy the above text to Expert View of Action2, it will show you a
message that it has made Action1 Reusable, just click ok.
RandomNumber is an Object.
RandomNumber(ParameterNameOrStartNumber [,EndNumber])
Open a new test and in the Expert view write these lines and run the test:
For i=1 to 5
var1=RandomNumber (0, 100
Msgbox(var1
Next
One more way is to define a Random Number parameter in the 'Parameter Options'
or 'Value Configuration Options' dialog box.
3. In the 'Input Parameters' area click on the '+' sign and enter the Name of the
input parameter as 'a', Type as Number, and Default value as 1. Click Ok.
4. Again right-click on Action1 in the keyword View , select 'Action Call Properties',
'Action Call Properties' window opens. Go to 'Parameter Values' Tab.
5. Make a single click under 'Value' column in the 'Input Parameter's' area, it will
become a button '<#>'. Click on this button.
7. Click on 'Parameter' radio button, select 'Random Number' from the dropdown. In
the Numeric Range enter 0 against From and 100 against To.
8. Click on 'Name' Checkbox and choose arg_a from the dropdown.
9. In the 'Generate New Random Number' area, select first option For each action
iteration . Click ok.
x=RandomNumber("arg_a")
Msgbox(x)
Randomize [number]
If Randomize is not used, the Rnd function (with no arguments) uses the same
number as a seed the first time it is called.
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
But if you omit randomize(2) from the above code and instead put only randomize
then at each run it generates different values.
For i= 1 to 3
Randomize
var1 = Int((6 * Rnd) + 1) ' Generate random value between 1 and 6
MsgBox var1
Next
Likewise
Int((6 * Rnd) + 1) ' Generate random value between 1 and 6.
The Rnd function returns a value less than 1 but greater than or equal to 0.
Rnd(number) If the number is Less than zero (< 0) then Rnd generates 'The same
number' every time, using number as the seed.
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
x=rnd(1)
Msgbox(x)
Next
If the number is Equal to zero (=0)then Rnd generates 'The most recently generated'
number.
For i= 1 to 3
x=rnd()
Msgbox(x)
Next
Remember:
For any given initial seed, 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.
Before calling Rnd, use the Randomize statement without an argument to initialize
the random-number generator with a seed based on the system timer
Test parameters
1. Open a New Test.
4. Enter the Name of the parameter as 'vartest' and its Default Value as 'hello'.
Click Apply and then Ok. The Type of this parameter is string.
6. Now in the Keyword View right click on Action1 and select 'Action Properties'.
'Action Properties' window opens.
8. Enter the Name of the parameter as 'varaction' and its Type as string and no
default value. Click Ok to come out of that window.
9. Again in the Keyword View right click on Action1 and select 'Action Call Properties'.
'Action Call Properties' window opens.
10. Go to 'Parameter Values' Tab. There you will see the 'varaction' action parameter
we created earlier. Make a single click under 'Value' heading, it will show a button
like this <#>. Just click on this button to open 'Value Configuration Options' window.
11. Click on 'Parameter' radio button and select 'Test/action Parameter' from that
dropdown.
12. 'Test Parameters' radio button will be selected by default and under 'Test
Parameters' radio button select 'vartest' from Parameter dropdown.[ remember this
vartest is a test parameter we created at the beginning]
13. When you click on ok to come out of 'Value Configuration Options' window, in the
'Action Call Properties' window, under 'Value' it will show <vartest>. Click Ok.
15. Now run the test. While running it will show 'hello' in the msgbox.
This example show how to declare test parameters and how to access those.
You can directly access test parameters only when parameterizing the value of a top-
level action input parameter or when specifying the storage location for a top-level
output parameter. To use values supplied for test parameters in steps within an
action, you must pass the test parameter to the action containing the step.
Alternatively, you can enter the parameter name in the Expert View using the
Parameter utility object, in the format: Parameter ("ParameterName").
Action Parameter
1. In the Keyword View right click on Action1 and select 'Action Properties'. 'Action
Properties' window opens.
3. Enter the Name of the parameter as 'a' and its Type as Number. In the same
way create another Number parameter 'b'.
4. Click Ok.
5. In the Keyword View right click on Action1 and select 'Action Properties'. 'Action
Properties' window opens. In the general tab, click on 'Reusable Action' checkbox at
the bottom to make the action reusable.
7. Go to Insert (menu)-> Call to New Action. 'Insert Call to New Action' window
opens. Just click ok to insert a new action.
10. In the keyword View right click on action2 and select 'Run from Step', it will show
you the sum 4 in msgbox.
How, for each row, in global data sheet, QTP iterates all rows of any action data
sheet.
2. Click on Record.
4. Enter the Agent Name as 'mary' and Password as 'mercury'. Click Ok (make sure
we click ok with mouse and not hit the return (enter) Key.)
5. When the Flight Reservation window is open, go to File ->Exit.
7. In the Keyword View under 'Value' column, make a single click on 'mary' (Agent
Name), a button like <#> will appear, click on this button to open 'Value
Configuration Options' window.
8. Click on Parameter radio button and select Data Table from the dropdown and let
rest everything be default. click ok to come out of that window.
9. In the Global Data sheet it will add a new columns with 'mary' as its first value.
11. For this action2, repeat steps from 2 to 7. (This time I have used the Agent
Name as 'bill')
12. After repeating step 7, when you click on 'Parameter' radio button and select
Data Table from the dropdown, make sure you select Current action sheet (local) in
the Location in Data Table area. Click Ok to close that window.
13. It will add a new column in action2 Data Sheet with 'bill ' (because I used bill as
an Agent Name ) as its first row.
14. Now you have two actions (action1 and action2), both of them do the same job
but their data is in different sheets.
15. Go to Global Data Sheet and Add one more row in it below 'mary'. I added
'rama'.
16. In the Local Data Sheet (action2) add two more rows to make them a total of 3.
I added 'amar' and 'Sumit'.
17. Right click on action1 and select action call properties, go to Run Tab and select
"Run on all rows" radio button. Do the same for action2.
18. Go to Expert View of action one and type : msgbox("acton1"). Now my action1
looks like this:
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, otherwise it will be fast and some
people may not able to understand.
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.
This is a very small tutorial on output values, just to make you familiar with the
process so that you can start on your own. For complete understanding of Output
values please see QTP User Guide.
1. Open a new test and also open a sample Flight application (Flight Reservation
window)
2.Make sure that both (new test and Flight Reservation window) are open and
visible.
5. QTP will be minimized and mouse pointer will take the shape of a hand. Click on
'Insert Order' button in 'Flight Reservation window.
7. "Output Value Properties" window opens with 'Insert Order' in the Name text field.
10. 'Output Options' window opens. In this window just click Ok. (It creates
Insert_Order_enabled_Out column in Global datasheet in Data Table with a Value
False in the first row)
11. It will bring you back to "Output Value Properties" window. Now earlier where
under Value it was showing False (see step 8) now it will show
Insert_Order_enabled_Out.
12. Again Click Ok to come out of this "Output Value Properties" window.
14. Now it means whatever the value of Insert Order button's Enable Property will
be, QTP will show that value in Data Table (under Insert_Order_enabled_Out
column) at Run time.
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 show a true value in there at run time. It will also show that captured
value in the Results window.
These above steps show you how to use output values with Data Table. Below
tutorial shows how to use output values with Environment variables.
1. Open a new test and also open a sample Flight application (Flight Reservation
window)
2. Make sure that both (new test and Flight Reservation window) are open and
visible.
7. "Output Value Properties" window opens with 'Insert Order' in the Name text field.
11. In 'Output Options' window, from 'Output Types' dropdown, select Environment,
and
click Ok.
13. Click Ok to come out of this "Output Value Properties" window. (You can check
that environment variable by going to File->Settings, Environment Tab and choosing
User-Defined from variable type)
14. Just add the below line in the Expert View at the end to see the value of the
environment variable.
msgbox(environment("Insert_Order_enabled_out"))
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 ). It will show a true value in there at run time. It will
also show that captured value in the Results window.
Parameterize Checkpoint
A small example:
You have certain user names (say 3 in our case) in the data table. You want that
only users which are in the data table should be able to login and other could not.
• While both yahoo mail login and QTP are open, click Record.
• Go to Insert->Checkpoint->Standard Checkpoint
• QTP will be minimized and mouse pointer will take the shape of a hand.
3. Stop recording.
4. Make sure you are in the Expert View. Right click on CheckPoint and select
CheckPoint Properties.
5. Checkpoint Properties window opens. Highlight the value property and Select
Parameter radio button.
6. Click on the Edit icon on the right side of the Parameter radio button.Parameter
Options window opens. Just select the Current action sheet (local) radio button.
8. Check the local data sheet. The first column name must be login_value.
9. Add any three names in the first three rows and modify the code as follows:
Total=DataTable.GetSheet[“Action1”].GetRowCount
Msgbox total
For i=1 to total
DataTable.SetCurrentRow (i)
a=inputbox(“enter value”)
Browser(“Yahoo! Mail: The best”).Page(“Yahoo! Mail : The
best”).WebEdit(login).Seta
Browser(“Yahoo! Mail: The best”).Page(“Yahoo! Mail : The
best”).WebEdit(login).Check CheckPoint(“login”)
Next
Now to see if our checkpoint really works use checkpoint return value (covered in
Tutorial 3) to check For every value you enter, if it is in the data table, it will return
true, otherwise false
You can create a Checkpoint while recording or editing a test. For this tutorial I will
take into account Text Checkpoint created through Standard Checkpoint while
editing.
Click on Record.
Enter the Agent Name as "Sachin" and Password as "mercury". Make sure you use
Tab key to move from one text box to another and hit Return (Enter) key after
entering the Password.
In the Keyword view go to the row which has "Sachin" under Value column. Right-
click anywhere on that row and choose "Insert Standard Checkpoint."
"Checkpoint Properties" window opens. 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, which you checked above, in order to
highlight it and make "Configure Value" area enabled.
In this area click on Parameter Radio button. This is all we need to do.
[On the right hand side of Parameter Radio button you will see Parameter Options
button (which has paper and pen image on it). you can click on it to see the default
values QTP has set for us.]
It will add a column in the Global Data Sheet with "Sachin" as its first value.
Add two more values in the subsequent rows. I added "aaaa" in the 2nd and "bbbb"
in the 3rd.
Now when we run the test and it opens the window where we need to enter the
Agent Name and Password, you have to enter Agent Name all of the 3 times (Just
enter the Agent Name, that's it, no Tab key or Return key). Make sure you enter
"Sachin" during first time, "aaaa" during second time and so on. We don't need to
enter the Password. Remember this is a Text Checkpoint on the "Agent Name" Text
field. 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. 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.
Image checkpoints are supported for the You can create Bitmap checkpoints for all
web add-in environment only. supported testing environments (As long
as the appropriate Add-ins are there)
Action input and Output Parameters
Those who are still confused about input parameters to actions and output values
from actions, just have a look at these examples, these act as a foundation for action
input and output values (this is ONE of the many ways, of course there can be other
ways of doing the things I have done below).
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.
a). Action output value (value returned by a called action) can be stored in a
variable
Go to Insert (Menu) -> Call to New Action, to add a new action at the end of the
test.
In the Keyword View, right click on Action1 and choose Action Properties.
Go to Parameters tab and create input variable in_a1_1 with Type as Number. Rest
everything be default.
(To create an input variable, you have to click on ‘+’ sign which is on the right hand
side of Input parameters section).
In the Parameters tab, also create one output variable out_a1_1 with Type as
Number
(To create an output variable, you have to click on ‘+’ sign which is on the right hand
side of Output parameters section).
s1=parameter("in_a1_1")
s2=parameter("in_a1_2
parameter("out_a1_1")=s1+s2
(When you copy this below code in Expert view of Action2, it may give you a warning
that it will make Action1 reusable, just click on Ok)
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.
b). Action output value (value returned by a called action) can be stored in
data table column.
Action output value (value returned by a called action) can be stored in data
table column.
Go to Insert (Menu) -> Call to New Action, to add a new action at the end of the
test.
In the Keyword View, right click on Action1 and choose Action Properties.
Go to Parameters tab and create input variable in_a1_1 with Type as Number. Rest
everything be default.
(To create an input variable, you have to click on ‘+’ sign which is on the right hand
side of Input parameters section).
In the Parameters tab, also create one output variable out_a1_1 with Type as
Number
(To create an output variable, you have to click on ‘+’ sign which is on the right hand
side of Output parameters section).
s1=parameter("in_a1_1")
s2=parameter("in_a1_2
parameter("out_a1_1")=s1+s2
In the Global Data Sheet, where you have column names as A, B and so on, double
click on A,
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.
c). Action output value (value returned by a called action) can be stored in
environment variable.
Go to Insert (Menu) -> Call to New Action, to add a new action at the end of the
test.
In the Keyword View, right click on Action1 and choose Action Properties.
Go to Parameters tab and create input variable in_a1_1 with Type as Number. Rest
everything be default.
(To create an input variable, you have to click on ‘+’ sign which is on the right hand
side of Input parameters section).
In the Parameters tab, also create one output variable out_a1_1 with Type as
Number
(To create an output variable, you have to click on ‘+’ sign which is on the right hand
side of Output parameters section).
s1=parameter("in_a1_1")
s2=parameter("in_a1_2")
parameter("out_a1_1")=s1+s2
Go to File-> Settings, Environment tab, in the 'Variable type' dropdown choose User-
defined. Click on the + sign which is on the right side.
‘Add New Environment Parameter’ window opens. Enter the Name of the parameter
as env_var and let the 'Value' field be empty and click on Ok.
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). 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 Keyword View, right click on Action1 and choose Action Properties.
Go to Parameters tab and create output variable out_a1_1 with Type as Any.
In the Keyword View, right click on Action2 and choose Action Properties.
Go to Parameters tab and create input variable in_a2_1 with Type as Any.
In the Keyword View, right click on Action1 and choose Action Call Properties.
In the Keyword View, right click on Action2 and choose Action Call Properties.
Action1 sums those values (2+2=4) and assigns the sum to out_a1_1 (Action1’s
output parameter).
Then Action1 passes the sum (i.e. 4) along with another number (3) to Action2 by
calling Action2 in its last line.
Action2 multiplies those two values (4, 3) it got from Action1 and passes on the
result of multiplication (12) and another number (5) to Action3, where these passed
on values are added and the result is shown in a message box.
2. Go to Insert-> Call to New Action, when ‘Insert Call to New Action’ window opens,
just click on Ok. This adds Action2.
4. In the Keyword View right click on Action1 and choose Action properties. Action
Properties window opens and go to Parameters tab.
5. In the Parameters tab, click on the +, which is on the right hand side of input
parameters. Add 1<sup>st</sup> input variable as in_a1_1 ( in means input, a1 is
for action1 and 1 is 1st variable) and keep its Type as Number, let all other things be
default.Similarly add 2nd input variable in_a1_2 and one output variable out_a1_1
also a Number Type.
6. Similarly add input and output parameters for Action2 (input variables in_a2_1 &
in_a2_2, output variable out_a2_1) and Action3
s1=parameter("in_a1_1")
s2=parameter("in_a1_2")
parameter("out_a1_1")=s1+s2
RunAction "Action2", oneIteration, parameter("out_a1_1"), 3
You can use any of the below options to get the background color:
Open http://www.google.com/
Write the below code (either 1 or 2) in the expert view of a new test and run it.
1) Var=Browser("Title:=Google").Page("Title:=Google").webelement("html
tag:=body", "height:=521").object.currentstyle.backgroundcolor
msgbox Var
OR
2) Var=Browser("Title:=Google").Page("Title:=Google”).object.bgcolor
msgbox Var
WebElement object is a general web object that may represent any web object. It is
never recorded, although we can use Description Programming with WebElement
object to perform methods on any web objects in the website.
For example:
[Open www.google.com]
If you write the below line in the expert view of a new test and Run it, it will click the
"I'm Feeling Lucky" button on the google page.
This same above line can be written using webelement object as:
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).
E.g. below you can see that when I tried to get the properties for a Label with the
help of an Object Spy, 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. So make sure to check for both run-time
and test properties before going to the conclusion that you cannot get the BackColor
of an object.
a=SwfWindow(“Teller”).SwfLabel(“window id:=98234”).Object.backcolor
Msgbox a
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 does not include these objects. For example, even if
the WebButton object on which you record is actually contained in several nested
WebTable objects, which are all contained within a Browser and Page, the recorded
hierarchy is only Browser > Page > WebButton
For Example (see below image) Object Spy identifies several levels of hierarchy for
Submit button, but while recording (or even when using Descriptive Programming) it
just uses the below line of code.
SwfWindow(“Teller”).SwfButton(“Submit”).Click