Friday, June 6, 2008

Import and Export Methods

Here i am giving the script for Importing data from data table and exporting the data table into Excel File.

SystemUtil.Run "C:\ProgramFiles\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe"

Dialog("text:= Login").Activate
Dialog("text: = Login").WinEdit("Attached text:=Agent Name").set "rajaputra"
Dialog("text: = Login").WinEdit("Attached text:=Password").set "mercury"
Dialog("text:=Login").WinButton("text:=OK").Click
Window("text:=Flight Reservation").Activate
datatable.importSheet "C:\example.xls",1,1
rowcount=datatable.GetRowCount
For i=1 to rowcount
Window("text:=Flight Reservation").WinButton("window id:=5").Click
Dialog("text:=Open Order").Activate
Dialog("text:=Open Order").WinCheckBox("text:=&Order No.").set "ON"
datatable.SetCurrentRow(i)
n=datatable(1,1)
Dialog("text:=Open Order").WinEdit("window id:=1016").set n
Dialog("text:=Open Order").WinButton("text:=OK").Click
If(window("text:=Flight Reservation").Dialog("text:=Open Order").Dialog("text:=Flight Reservation").exist)then
window("text:=Flight Reservation").Dialog("text:=Open Order").WinButton("text:=Cancel").Click
datatable(2,1)="Not Exist"
Else
datatable(2,1)="Exist"
End If
Next
Datatable.Export ("C:\flights.xls")
window("text:=Flight Reservation").Close


Before running this script, in "example.xls" you have to put two columns.
one is OrderNo and one is Result.
In OrderNo you can enter any valid or invalid OrderNo's and Result you can leave as it is.
We will out put the data into Results.

No comments:

About Me

My photo
Hi all,I am Arun Singh Rajaputra. I am working as a Project Lead in a reputed organization in Hyderabad, AP, India. I have little bit knowledge on Quick Test Professional and like to share my knowledge to all through this blog.

Subscribe to get updates on this blog

Enter your email address:

NOTE

Some of the posts posted in this blog are collected and most of them have been prepared by me. If any one have objections regarding any copied posts. Please mail me so that I can take a necessary action on that post.