Search code examples
vbscriptruntime-errorqtphp-uft

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.


Solution

  • 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