Thursday, 30 August 2012

L15 - Standard Output Value


It reads the standard value from any object and place the value in datatable run time dynamically.

Step 1

Start recording.

Step 2

Goto Menu Insert -> Output value -> Standard output value.


Step 3

Select "Agent Name" in the example and a window will open "Object selection: output value properties"
Objective is to select object from where we have to take output value.
Press Ok.

Step 5

Select the property in "Object value properties" window the value of which is required at run time.

Configure value:
To configure the value option is there in lower side of window. 


Step 6

Press Ok and the code as below gets generated and a column is added in the datasheet where the value will come during run time.


Step 7

Dialog("Login").WinEdit("Agent Name:").Output CheckPoint("Agent Name:")
x = datatable.Value("Agent_Name_text_out", dtlocalsheet)
Msgbox x


Step 8

It will show the current value in the text box.

Wednesday, 29 August 2012

L16 - Text Output Value


It reads the TEXT from any object and place the value in data table run time dynamically.

Application used: Flight reservation

Step 1
Record -> Insert -> Output Value -> Text Output Value
The cursor will change to hand icon-> Click the hand icon on the object from where text value needs to be retrieved run time.
Step 2
“Object selection – Text Output value” window will come -> Press Ok.
Step 3
Text Output Value properties window will come.
We can modify the Output text here, Press Ok.
Code as below will get generated automatically and a column will be inserted in datatable.
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Output CheckPoint("From")
To read the value from Datatable, write the code as below.
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Output CheckPoint("From")
x=datatable.Value("FromOutput_Text_out", dtgglobalsheet)
msgbox x
Step 4
Run the test, it will show the output value in Message Box.





Friday, 24 August 2012

L17 - Text Area Output Value


It reads the TEXT from any object and place the value in data table run time dynamically.

Application used: Flight reservation

Step 1
Record -> Insert -> Output Value -> Text Area Output Value
The cursor will change to MARKER -> Select the text from the object from where text value needs to be retrieved run time.

Step 2
“Object selection – Text Output value” window will come -> Press Ok.

Step 3
Text Output Value properties window will come.
We can modify the Output text here, Press Ok.
Code as below will get generated automatically and a column will be inserted in datatable.
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Output CheckPoint("From")
To read the value from Datatable, write the code as below.
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Output CheckPoint("From")
x=datatable.Value("FromOutput_Text_out", dtgglobalsheet)
msgbox x

Step 4
Run the test, it will show the output value whatever is there during run time in Message Box.







Tuesday, 21 August 2012

L18 - Datatbase Output Value

It inserts values in the datatable in the run time from the database as per the sql query defined and we can use the same value in run time.

Step 1

Goto Menu -> Insert -> Output value -> Database output value. 

Step 2

Database Query wizard will open.
Select "Create query using Microsoft query".
Press Next

Step 3

select MS Access database as per are taking example with MS access database.

Step 4

Select the database that is being used.

Step 5

Select all the fields of table that we want to use.

Step 6

Put conditions for query.

Step 7

Select option "Exit and return to Quick test professional'

Step 8

database output value properties window opens.
It shows all the output values of the fields/query selected.
We can configure the output values in lower portion of the widow using Modify button.
 If we press Ok -> we can see the columns created as per the parameter data in data table as shown below.

Step 9


DbTable("DbTable").Output CheckPoint("DbTable")
x=Datatable.Value("DbTable_Row_1_Col_1_out", dtlocalsheet)
Msgbox x

Value comes in variable x during run time and we can use it as per our requirement.

Step 10



Sunday, 19 August 2012

L19 - XML Output Value


Step 1 Make a sample xml file as below

<note>
<to>To</to>
<from>Manu</from>
<heading>Learn</heading>
<body>today</body>
</note>

Step 2

To set XML Output Valuet (From resource) Go to Menu Insert -> Output Value -> XML Output Value  (From resource)

Step 3 

Option to choose XML file from source will come, choose any xml file saved to the system.

Step 4

Now a new window will open with name "XML Output properties", check the check boxes on left side whatever needs to be as Output during runtime and press Ok.

A line of code will generate for xml check point as below:

XMLFile("text.xml").Output CheckPoint("text.xml")
We can read the value using below code.
x=datatable.Value("value_from_out", dtgglobalsheet)
msgbox x



Friday, 10 August 2012

L20 - Repository Manager

Repository manager

Object repository manager can be used to save repository and use the repository in any test.

Step 1

Goto Menu -> Resources ->Object repository manager

Step 2

In this example we are taking Calculator as application.

Step 3

Create Object repository for Calculator.

Step 4

Press Ok

Step 5

Click in Save button to save the Object Repository.
It should be saved with extension ".tsr" 

Step 6

Goto Keyword view -> Action -> Right click -> Action properties

Step 7

Click on + button to add repository, select the repository saved in previous step.


Step 8


Step 9

Select saved repository.

Step 10

Press Ok.

Step 11

Now if we Goto -> Menu -> Object Repository -> Object Repository .

Step 12

External repository can be seen added to the test but is is not editable, to make changes in Object repository, Goto Object Repository manager -> Open the repository and edit it.

Monday, 6 August 2012

L21 - Associate Repository Manager




Topic : Associate repository manager


Step 1.


Step 2. Click on PLUS (+) button and add saved .tsr file

Step 3. Add Available actions in Associated actions


Step 4. Now Press OK and the shared repository is added to the test, Goto Object repository

Step 5. You can see now that the shared repository is added to the test but it is not editable.


Sunday, 5 August 2012

L22 - Associate Repository, VBS file


We can use Function libraries to write all our functions and then we can associate these function libraries and use in the test, below is the example to create a VBS (Function library) and call it in test.
There are 2 ways we can associate Function library in any test.
1.    By Code using Executefile function
2.    By adding library in function.

Step 1
File -> New -> Function library

Step 2
Add a function a below to return some value as showing the input 2 times.
Public function funadd(str)
str=str+str
funadd=str
End Function
Save the function library with extension .VBS.

Step 3
3.1 Now we can call Executefile as below
executefile ("C:\QTP Test Class\Manu\misc\callfun.vbs")
x=funReturnDoubleInputValue("Manu")
msgbox x
3.2
There is an alternate also, we can add using Home -> Settings -> Resources-> Associate function library. 



Friday, 3 August 2012

L23 - Regular Expression


We can use Regular expression where ever there is need of some conditional checkpoint, like if there is a condition that to check that order number should start with 1.

We can put a standard checkpoint and use the regular expression in standard checkpoint, while editing the standard checkpoint, we see a “Regular Expression” button next to the value of Constant/Parameterization.

Click on this button, “Constant value option” window will open.

Check the check box at the left side of “Regular Expression”

To put condition for any value after first digit as 1 use “1. *”
It will check for any value starting with 1.


Wednesday, 1 August 2012

L24 - Working with Notepad

Problem statement : Working with notepad, open edit, write and close, here is an example of reading an ID saved in notepad and replace it with new ID that is entered in input box.

' Input box gets the ID saved previous time mechanism
' create the Final report file
Const ForAppending=8  ' We have to use second argument in OpenTextFile as value 8 . for appending mode.
Dim objFSO,objSetTextFile,strFileToWriteID
strFileToWriteID= "C:\QTP Test Class\Manu\Notepad\ID.txt"
' create object
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objSetTextFile = objFSO.OpenTextFile(strFileToWriteID,ForAppending)' Open it in Append Mode
objSetTextFile.WriteLine "Manuj"
objSetTextFile.close


' if does not exist then write the default TSOID first and close the object
If (objFSO.FileExists(strFileToWriteID)) Then
Else
Set objSetTextFile = objFSO.OpenTextFile(strFileToWriteID,ForAppending)' Open it in Append Mode
objSetTextFile.WriteLine "Manuj"
objSetTextFile.close
End if

' Read the TSO ID from the notepad file
Set objFSOInput = CreateObject("Scripting.FileSystemObject")
Set objReadFile = objFSOInput.GetFile (strFileToWriteID)
Set objReadFile = objFSOInput.OpenTextFile(strFileToWriteID, 1)   
strTSOID=ucase(trim(objReadFile.ReadLine))
objReadFile.close
' close the read object
strID=InputBox ("Enter ID used for the files ","Enter ID",strTSOID)

' Write the new ID in the file

If (objFSO.FileExists(strFileToWriteID)) Then
set f=objFSO.GetFile(strFileToWriteID)
f.Delete
End if

Set objSetTextFile = objFSO.OpenTextFile(strFileToWriteID,ForAppending,True)' Open it in Append Mode
objSetTextFile.WriteLine strID
objSetTextFile.close