Exforsys

Online Training

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 ...


Go Back   Exforsys > Testing > Software Testing

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-24-2007, 03:07 PM
Junior Member
 
Join Date: May 2007
Posts: 20
nehasahu is on a distinguished road
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 codehere 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-24-2007, 04:33 PM
Senior Member
 
Join Date: Apr 2006
Posts: 141
Adrian is on a distinguished road
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-24-2007, 08:17 PM
Junior Member
 
Join Date: May 2007
Posts: 20
nehasahu is on a distinguished road
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-29-2007, 12:35 PM
rameshrise's Avatar
Junior Member
 
Join Date: May 2007
Posts: 2
rameshrise is on a distinguished road
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 06-01-2007, 06:39 AM
bharathp's Avatar
Member
 
Join Date: May 2006
Location: Banglore,India
Posts: 85
bharathp is on a distinguished road
Send a message via AIM to bharathp
HI
RammY Is Right
Just follow the Rammy Instructions
__________________
Bharath Kumar.P
Test Engineer
Banglore, India
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 06-01-2007, 10:49 PM
Junior Member
 
Join Date: May 2007
Posts: 20
nehasahu is on a distinguished road
Thanks a Adrian, Rammy and Bharath....
My code is working now
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) Steve Summit Tech FAQ 0 06-01-2004 07:01 AM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit Tech FAQ 0 06-01-2004 07:00 AM
comp.cad.autocad AutoLISP FAQ (part 1/2) - general Reini Urban Tech FAQ 0 06-01-2004 06:30 AM
comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) Steve Summit Tech FAQ 0 05-15-2004 07:00 AM
comp.cad.autocad AutoLISP FAQ (part 1/2) - general Reini Urban Tech FAQ 0 05-01-2004 06:30 AM


All times are GMT -4. The time now is 09:56 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.