
- Forum
- Testing
- Software Testing
- QTP (Code)
QTP (Code)
This is a discussion on QTP (Code) within the Software Testing forums, part of the Testing category; Can anybody help me out with this: I dont know how to use Regular expression...I have a object which changes ...
-
QTP (Code)
Can anybody help me out with this:
I dont know how to use Regular expression...I have a object which changes at Run time.
Window("Flight Reservation").Dialog("Fax Order NO.273)).ActiveX(MaskEdBox).Type 9143234447
============================================
in this code the Fax Order no. 273 changes at run time :
to solve this I have written this code
here orno is a variable which traps the order number from the datatable)
Set hello = Description.Create()
hello("text").Value = "Fax Order No."& orno
Window("Flight Reservation").Dialog(hello).ActiveX(MaskEdBox).Type "9143734449"
But this code is giving me an error....
Really dont know how to solve it ....If anybody can solve this out i will be really grateful to him.
Thanks in advance
-
You have not given what error you have got. Kindly paste the exact error message you have got which would help us to resolve your problem. Also post here the query how you got order number from the data table and store in orno variable.
-
QTP code
Hi Adrian,
I am getting following error:
Failed to run the test due to an unknown error.
=============================================
on my program reaches this line
Window("Flight Reservation").Dialog(hello).ActiveX(MaskEdBox).Type "9143734449"
==========================================================
Actually two days back only i have taken some lessons on QTP. so i am very new to it.
orno=DataTable("ORDERNO",dtGlobalSheet)
I have declared a variable orno which is trapping the orderno from the dtGlobalSheet.
you must be knowing about the Flight application which gets downloaded automatically when you download QTP.
I want to write a program so that the order no which is generated automatically when we insert the order...is trapped in the datatable ....then and orno variable will pick up the data from the datatable.
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set orno
I am pasting the whole program here:
PROGRAM FOR PARAMETER
SystemUtil.Run "C:\QTP\samples\flight\app\flight4a.exe","","C:\QTP\samples\flight\app\","open"
Dialog("Login").WinEdit("Agent Name:").Set "rinki"
Dialog("Login").WinEdit("Password:").SetSecure "46532736298ec0a3974b060d73f34ba93f93c4ec"
Dialog("Login").WinButton("OK").Click
'TAKING VALUES FROM THE DATATABLE AND PUTTING IT IN THE APPLICATION
For i=1 to datatable.GetRowCount
datatable.SetCurrentRow i
Window("Flight Reservation").WinMenu("Menu").Select "File;New Order"
Window("Flight Reservation").ActiveX("MaskEdBox").Type DataTable("FD", dtGlobalSheet)
Window("Flight Reservation").WinComboBox("Fly From:").Select DataTable("ff", dtGlobalSheet)
Window("Flight Reservation").WinComboBox("Fly To:").Select DataTable("ft", dtGlobalSheet)
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select 0
Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation").WinEdit("Name:").Set DataTable("name", dtGlobalSheet)
'RANDOMIZE FUNCTION WILL TAKE THE VALUES RANDOMLY AND PUT IT IN THE
'TICKETS(SET.TICKECTS)
Randomize
upperbound = 10
lowerbound = 1
tickets = Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
Window("Flight Reservation").WinEdit("Tickets:").Set tickets
Window("Flight Reservation").WinButton("Insert Order").Click
'SETTING A synchronization point
Window("Flight Reservation").ActiveX("Threed Panel Control").WaitProperty "attached text", "Insert Done...", 10000
'Checkpoint for Insert Done
expInsertDone = "Insert Done..."
actInsertDone = Window("Flight Reservation").ActiveX("Threed Panel Control").GetROProperty("text")
'msgbox (actInsertDone)
If (strcomp(expInsertDone,actInsertDone) = 0) Then
Reporter.ReportEvent 0,"Insert Done", "The record has been inserted."
else
Reporter.ReportEvent 1,"Insert Done","The record was not inserted."
End If
Dim ono
ono= Window("Flight Reservation").WinEdit("Order No:").GetROProperty("text")
DataTable("ORDERNO",dtGlobalSheet)=ono
'strcpy DataTable("ORDERNO",dtGlobalSheet),"C:\Documents and Settings\shonu\Desktop\taekwondo.txt"
orno=DataTable("ORDERNO",dtGlobalSheet)
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order..."
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set orno
wait (2)
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Window("Flight Reservation").Activate
wait (1)
'=================================================================
'comparing the data which is there in the application with the Data table.......
'Comparing Flight date
Dim act1, exp1,act2,exp2,act3,exp3,act4,exp4
act1=DataTable("FD",dtGlobalSheet)
exp1=Window("Flight Reservation").ActiveX("MaskEdBox").GetROProperty("text")
If act1=exp1 Then
'msgbox "they are equal"
Reporter.ReportEvent micPass,"whether both the values match or not","Matching"
else
'msgbox "they are not equal"
Reporter.ReportEvent micFail,"whether both the values match or not","Not matching"
End If
'Comparing fly_from
act2=DataTable("ff",dtGlobalSheet)
exp2=Window("Flight Reservation").WinComboBox("Fly From:").GetROProperty("text")
If act2=exp2 Then
'msgbox "they are equal"
Reporter.ReportEvent micPass,"whether both the values match or not","Matching"
else
' msgbox "they are not equal"
Reporter.ReportEvent micFail,"whether both the values match or not","Not matching"
End If
'Comparing Fly to
act3=DataTable("ft",dtGlobalSheet)
exp3=Window("Flight Reservation").WinComboBox("Fly To:").GetROProperty("text")
If act3=exp3 Then
'msgbox "they are equal"
Reporter.ReportEvent micPass,"whether both the values match or not","Matching"
else
'msgbox "they are not equal"
Reporter.ReportEvent micFail,"whether both the values match or not","Not matching"
End If
'Comparing Name
act4=DataTable("name",dtGlobalSheet)
exp4=Window("Flight Reservation").WinEdit("Name:").GetROProperty("text")
If act4=exp4 Then
' msgbox "they are equal"
Reporter.ReportEvent micPass,"whether both the values match or not","Matching"
else
'msgbox "they are not equal"
Reporter.ReportEvent micFail,"whether both the values match or not","Not matching"
End If
Window("Flight Reservation").Activate
Window("Flight Reservation").WinMenu("Menu").Select "File;Fax Order..."
wait(1)
Window("Flight Reservation").Dialog("Fax Order No. 271").SetTOProperty "Fax Order No. 271", orno
'
wait (1)
Set hello = Description.Create()
hello("text").Value = "Fax Order No."& orno
Window("Flight Reservation").Dialog(hello).ActiveX(MaskEdBox).Type "9143734449"
wait(1)
'Window("Flight Reservation").Dialog("Fax Order No. 303").WinCheckBox("Send Signature with order").Set "ON"
'Window("Flight Reservation").Dialog("Fax Order No. 303").Drag 234,208
'Window("Flight Reservation").Dialog("Fax Order No. 303").WinObject("Fax").Drop 328,188
Window("Flight Reservation").Dialog(ButDesc).WinButton("Send").Click
'Window("Flight Reservation").Dialog("Fax Order No. 303").Activate
'Window("Flight Reservation").Activate
Next
Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"
Please help me out.
Thanks
-
05-29-2007, 12:35 PM #4
- Join Date
- May 2007
- Answers
- 2
Hi,
Here in Regular expression if the order no is 3 digit no create regular expression with [0-9][0-9][0-9] and it consider any 3 digit number changing dynamically.
Thanks
Rammy
-
HI
RammY Is Right
Just follow the Rammy Instructions
-
Thanks a Adrian, Rammy and Bharath....
My code is working now
-
I really enjoyed this. where can I find more info about this. email me..Can anybody help me out with this:
I dont know how to use Regular expression...I have a object which changes at Run time.
Window("Flight Reservation").Dialog("Fax Order NO.273)).ActiveX(MaskEdBox).Type 9143234447
============================================
in this code the Fax Order no. 273 changes at run time :
to solve this I have written this code
here orno is a variable which traps the order number from the datatable)
Set hello = Description.Create()
hello("text").Value = "Fax Order No."& orno
Window("Flight Reservation").Dialog(hello).ActiveX(MaskEdBox).Type "9143734449"
But this code is giving me an error....
Really dont know how to solve it ....If anybody can solve this out i will be really grateful to him.
Thanks in advance
-
Sponsored Ads

Reply With Quote






