Can't execute code PL HELP!

45 views
Skip to first unread message

Ashfaque

unread,
Dec 26, 2012, 9:48:33 PM12/26/12
to qtp-ele...@googlegroups.com
Hello Team/ Karthik:

We (myself and a friend both QTP premium members) are trying to follow the video recorded video 04-08 DDF (26:00 min approx) on our own. So we wrote our own code with slightly different names of objects.
We were trying to put into action the Set system of object creation. However the code stops at this line: 
Set myP = Browser("IE").Page("Page 1") (Shown in bold below.)
I get the following error message: "variable is undefined 'myP'
However, it WORKS when we take Option Explicit off? 
Can someone tell us what's going on?


Option Explicit


Dim vCost, vEndMiles, vStartMiles, vMileGallons
Dim vURL

vCost = 4
vEndMiles = 80000
 vStartMiles = 60000
 vMileGallons = 100
 vURL = "http://www.calculator.net/gas-mileage-calculator.html"

'Browser("IE").Page("Page 1").WebEdit("EndMiles").Set vEndMiles
'Browser("IE").Page("Page 1").WebEdit("StartMiles").Set vStartMiles
'Browser("IE").Page("Page 1").WebEdit("Cost").Set vCost
'Browser("IE").Page("Page 1").WebEdit("Mile_Gallons").Set vMileGallons

Systemutil.Run("iexplore.exe"), vURL
Set myP = Browser("IE").Page("Page 1") CODE DOES NOT EXECUTE HERE
myP.WebEdit("EndMiles").Set vEndMiles
myP.WebEdit("StartMiles").Set vStartMiles
myP.WebEdit("Cost").Set vCost
myP.WebEdit("Mile_Gallons").Set vMileGallons

iTeLearn Help Team

unread,
Dec 26, 2012, 10:40:40 PM12/26/12
to Ashfaque, qtp-ele...@googlegroups.com
Ashfaque,

You need to declare the variable myP as you used the command Option Explicit.

Thanks,


--
You received this message because you are subscribed to the Google Groups "QTP eLearn Team" group.
To unsubscribe from this group, send email to qtp-elearn-te...@googlegroups.com.
Visit this group at http://groups.google.com/group/qtp-elearn-team?hl=en-US.
 
 



--
iTeLearn Help Team
tech...@iTeLearn.com
QTPeLearn.com | SeleniumeLearn.com
Join me on YouTube and LinkenIn

Ashfaque Swapan

unread,
Dec 26, 2012, 10:58:55 PM12/26/12
to iTeLearn Help Team, qtp-ele...@googlegroups.com
Many thanks, everyone. Happily, I figured that out myself after progressing a bit further in the video where Karthik faces the same issue.
--
Ashfaque Swapan
Phone: (510) 356-6168

Staff reporter,
India-West newspaper
933 MacArthur Blvd
San Leandro, CA 94577.

www.indiawest.com
Reply all
Reply to author
Forward
0 new messages