Forum Discussion

GAutomation's avatar
GAutomation
Frequent Contributor
6 years ago
Solved

when it is not able to find an object it is not returning correct value

function click_btn(window,propertyname) set currentObj = findObject(propertyname) if (isobject(currentObj ) then currentObj.click log.Message("button is exist")   else log.Message("butt...
  • tristaanogre's avatar
    6 years ago

    Your problem is in your findObject.  If it doesn't find the object, then found = false and "false" is not an object.

     

    I think this is a better, more elegant way of doing the same thing... fewer variables and a more direct result.

     

    function findObject(propertyname)
    
    if propertyname <> undefined then
    
    set name = windows.Find("Name",propertyname,10)
    
    end if
    
    if name.Exists then
    
    set findObject = name
    
    else
    
    set findObject = Utils.CreateStubObject
    
    end if
    
    end function