Forum Discussion

Rajesh2's avatar
Rajesh2
Contributor
7 years ago
Solved

How to click after finding an object

Hi All,

 

I need to perform some action after finding an object using Find, FindAll or FindChildren methods. 

 

Can anyone please explain how to go about this?

 

Like click on the object after finding it using Find or FindAll methods.

 

I have gone through the smartbear website for find and findAll. But it didnt help.

 

I tried with this code:

 

def clickControlID():
  TestedApps.Sound_PE.Run()
  Delay(5000)
  Login=Sys.Process("SoundPE").WinFormsObject("DialogLogin")
  clkLogin=Login.FindAllChildren("WinFormsControlName","buttonOK",20)
  clkLogin.Click()

 

I am getting the error for this code as:

AttributeError:
'SafeArrayWrapper' object has no attribute 'Click'
  • clkLogin=Login.FindAllChildren("WinFormsControlName","buttonOK",20)

     

    FindAllChildren() will return an array of objects. 

     

    Click() method can be performed only on single object. 

    You need to use Find() or FindChild() method or select appropriate object from the returned array.

4 Replies

  • baxatob's avatar
    baxatob
    Community Hero
    clkLogin=Login.FindAllChildren("WinFormsControlName","buttonOK",20)

     

    FindAllChildren() will return an array of objects. 

     

    Click() method can be performed only on single object. 

    You need to use Find() or FindChild() method or select appropriate object from the returned array.

  • shankar_r's avatar
    shankar_r
    Community Hero

    try this,

     

    def clickControlID():
      TestedApps.Sound_PE.Run()
      Delay(5000)
      Login=Sys.Process("SoundPE").WinFormsObject("DialogLogin")
      clkLogin=Login.FindAllChildren("WinFormsControlName","buttonOK",20)
    Sys.HighlightObject(clkLogin)

     

    let me know you are able to identify the object.

     

    If you are able to highlight the object then you put a breakpoint on the Sys.HighlightObject(clkLogin) and add clkLogin in the watch list and see what is the properties you got.