简体   繁体   中英

QTP - Object doesn't support this property or method error

I am not sure what's wrong with the below code.

    Set obj=description.Create()

    obj("micClass").Value="Link"
    obj("name").Value="Advertising Programs"

    Set totalnobuttons=Browser("title:=.*").Page("title:=.*").ChildObjects(obj)
    totalnobuttons.highlight
    print totalnobuttons.count

    For i=0 to totalnobuttons.count-1
        print totalnobuttons(i).GetRoProperty("name")
    Next

This gives an error "Object doesn't support this property or method error" during execution. I need to highlight the "Advertising Programs" program link using the above code.

Your line:

totalnobuttons.highlight

is a culprit. You are trying to highlight the whole collection of Link objects. You cannot do that. Instead, remove that line and put that in your For...Loop like this:

For i = 0 to totalnobuttons.count-1
    totalnobuttons(i).HighLight
    print totalnobuttons(i).GetRoProperty("name")
Next

You are trying to find collection object. Return type should be always array of objects. Try to use advanced for loop to proceed. Find the code below:

For each button in totalnobuttons
    button.HighLight
    print button.GetRoProperty("name")
Next

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM