Descriptive Programming to Open Order in Flight Application

Descriptive Programming to open order in flight application

window("text:=Flight Reservation").winmenu("menuobjtype:=2").Select "File;Open Order..."
window("text:=Flight Reservation").Dialog("text:=Open Order").Click
Window("text:=Flight Reservation").Dialog("text:=Open Order").WinCheckBox("text:=&Order No.").Set "ON"
Window("text:=Flight Reservation").Dialog("text:=Open Order").WinEdit("window id:=1016").Set "4"
Window("text:=Flight Reservation").Dialog("text:=Open Order").WinButton("text:=OK").Click

D.P for Flight Application Login

QTP Script to Create MSWORD Document

QTP Script to create New MicroSoft Word Document

Dim obj
Set obj = CreateObject("Word.Application")
obj.Documents.Add
obj.Selection.TypeText"Hiiiiiiiiiiiiiiii"
obj.ActiveDocument.SaveAs"c:\Test.doc"

QTP Script to Create Excel Sheet

QTP Script to Create Notepad

Steps to Call Function from QTP

This post is about how to call Function from QTP.

Function:-Its a block of statements that perform a particular task.

Open a notepad and paste the code shown below.

Function f1
msgbox "hiii"
msgbox "function demo "
End Function

and save it as abc.vbs

.vbs is extension for vb script files.

f1 is function name and abc is file name.

Now open a new test and associate the function to new test as shown below

Navigation for associating is:-

1.Click menu item Test.
2.Select option Settings(U can see a window named Test Settings).
3.Click on Resources Tab(U can see + symbol which is used to add a new file to test).
4.Click on + symbol and browse the desired file(here abc.vbs).
U can see ur file path in Associated library files
5.Now click on Ok button.

Note:-This navigation is for QTP 8.2

Now its time to call function just write function name in test and run.

Here in this example function name is f1 so type f1 and run the test.

In this way u can call functions wherever required in ur script.

Let me know your suggestions and opinions on this blog.

QTP Script to display System Date and Time

QTP Script to display System Date and Time

msgbox now

Above code will display System Date and Time = 5/20/2008 9:01:05 AM

msgbox date

Above code will display only System Date = 5/20/2008

msgbox time

Above code will display only System Time = 9:01:05 AM

QTP Script to get RowCount of DataTable for Specific Column

QTP Script to get rowcount of datatable for specific column.

count1=0
For i=0 to datatable.GetRowCount-1
a= datatable.Value("A")
datatable.SetNextRow
If a<>vbNullstring Then
count1=count1+1
End If
Next
msgbox count1

where A is column name(in datatable).

QTP Script to get DataTable ColumnCount,Adding new Column to Datatable,Getting Datatable Column Names

QTP Script to find Local Host Name of System

QTP Script to find Local Host of System

msgbox Environment("LocalHostName")

QTP Script for Comparing Actual Values with Expected Values and to Set Result as Pass or Fail

QTP Script for comparing Actual Result with Expected Result.



Below Script is used to compare actual and expected values in calculator application.
We are supplying values to value1 and value2 textboxes from datatable.Column A of datatable to value 1 and column B to value 2.

In datatable we have columns A,B,E.V,Res

E.V is Expected value column in which we enter values.These values are compared with Actual values.

Res is empty column which is filled at run time by QTP.We can see result as Pass or Fail in Res column in Run Time Datatable.

VbWindow("Form1").VbEdit("val1").Set DataTable("A",1)
VbWindow("Form1").VbEdit("val2").Set DataTable("B",1)
VbWindow("Form1").VbButton("ADD").Click
Expval=DataTable.Value("E.V",1)
Actval=VbWindow("Form1").VbEdit("res").Getroproperty("text")
If (Expval=Actval) Then
DataTable("Res",1)="Pass"
else
DataTable("Res",1)="Fail"
End If

We are getting value from datatable(E.V Column) to Expval variable,Capturing Actval from application(result textbox) and comparing them and assigning value to Res column as Pass or Fail.

Output will be

A B E.V Res
1 1 2 Pass
2 2 3 Fail
3 3 6 Pass
4 4 8 Pass
5 5 11 Fail

Related Posts Plugin for WordPress, Blogger...

Fun and Knowledge