Micro Focus QTP (UFT) Forums
Error object doesnt support this property or method - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Error object doesnt support this property or method (/Thread-Error-object-doesnt-support-this-property-or-method)



Error object doesnt support this property or method - seerick - 06-07-2013

I've been trying to get around this for a while and can't seem to get it. The code below gives the error

"Object doesn't support this property or method: rCount=Browser("Yahoo!").Page("Yahoo! Finance - Business").WebTable("Most Actives","index:=0").RowCount"

The end result I'm trying to achieve is copy data from "Most Actives" table on this site and paste it into a text document.

Any ideas? Thanks



Code:
Browser("Yahoo!").Page("Yahoo!").Link("Finance").Click          
Browser("Yahoo!").Page("Yahoo! Finance - Business").Sync
Wait 10

Dim rCount
Dim cCount
Dim cData

rCount=Browser("Yahoo!").Page("Yahoo! Finance - Business").WebTable("Most Actives","index:=0").RowCount
cCount=Browser("Yahoo!").Page("Yahoo! Finance - Business").WebTable("Most Actives","index:=0").ColumnCount
For r=1 to rCount
cCount=Browser("Yahoo!").Page("Yahoo! Finance - Business").WebTable("Most Actives","index:=0").ColumnCount(r)
For c=1 to cCount
cData=Browser("Yahoo!").Page("Yahoo! Finance - Business").WebTable("Most Actives","index:=0").GetCellData(r,c)

msgbox cData
Next
Next



RE: Error object doesnt support this property or method - Ankur - 06-07-2013

Looks like you're using Descriptive Programming there -

Code:
.WebTable("Most Actives","index:=0").
Most Actives should have a property name


RE: Error object doesnt support this property or method - seerick - 06-08-2013

Hi Ankur

Thank you for the response. I'm not exactly sure what you mean by property name. Using the object spy I try adding a few attributes to try and specify the table further but it gave the same error. Would you kindly give an example of this "property name"

Edit: The "Most Actives" I got from the object spy, it was the name of the webtable it came back with after clicking on the table "WebTable: Most Actives"

Code:
.WebTable("Most Actives","index:=0","html tag:=TABLE","name:=BAC")



RE: Error object doesnt support this property or method - Ankur - 06-08-2013

I mean, the code should look something like

Code:
.WebTable("PropertyName:=Most Actives","index:=0").

given that the syntax is
Code:
.WebTable("PropertyName1:=PropertyValue1","PropertyName2:=PropertyValue2" .....).



RE: Error object doesnt support this property or method - seerick - 06-08-2013

Ah ok, that makes sense.

Well, tried that and it seemed to solve that error but led to a new one.

Code:
Wrong number of arguments or invalid property assignment: 'Browser(...).Page(...).WebTable(...).ColumnCount'

Line (10): "cCount=Browser("Yahoo!").Page("Yahoo! Finance - Business").WebTable("PropertyName:=Most Actives","index:=0","html tag:=TABLE").ColumnCount".

Just in case it helps, the script runs, opens the page but acts like it gets stuck in loop. After letting it run 3-4 minutes I manually stop, thats when the error pops.


RE: Error object doesnt support this property or method - seerick - 06-08-2013

Disregard, I got it to work somehow.
I used a different block of code I found and modified it but, it'll take a bit I think to figure out why this one works while the other doesn't. Thank you for your help Smile

Working Code:

Code:
Dim res
Dim res1
Dim res2
Dim i,j
res =Browser("Yahoo!").Page("Yahoo! Finance - Business").WebTable("PropertyName:=Most Actives","index:=6").RowCount
res1=Browser("Yahoo!").Page("Yahoo! Finance - Business").WebTable("PropertyName:=Most Actives","index:=6").ColumnCount(res)

For i=1 to res
For j=1 to res1
  res2=Browser("Yahoo!").Page("Yahoo! Finance - Business").WebTable("PropertyName:=Most Actives","index:=6").GetCellData(i,j)
msgbox res2
next
next



RE: Error object doesnt support this property or method - Ankur - 06-08-2013

PropertyName I mentioned above was just a place holder, it should be replaced with an actual property name.


RE: Error object doesnt support this property or method - seerick - 06-08-2013

Ah ok. I guess thats why when I change the "index" number it is cycling through all webtables. The "PropertyName:=Most Actives" isn't really doing anything in this case.

So I guess what I need to figure out is what property IS "Most Actives"
When I use the object spy it says the WebTable: Most Actives, with a variety of attributes. Thats why I put the Most Actives in the webtable function in the first place.

One of the attributes of the Webtable is name:=BAC but it doesn't seem to like that. I'll just have to play around with it some more to try and figure out how to specify what element I want rather than trial and error with index #