Forum Discussion

farhanahmed's avatar
farhanahmed
Contributor
14 years ago

How to click buttons though loop.

Hi

I have a scenarion in which i have 40 buttons on a from and instead of clicking every button one by one i want click these buttons through loop, can any body tell me how can i click these buttons though loop.

where as every button have different object name!

Thanks and Regards

-fani

7 Replies

  • sastowe's avatar
    sastowe
    Super Contributor
    I might place the object names in an array.



    sObjName = "Name1|Name2|Name3|Name4"

    asObjName = Split(sObjName, "|")



    Then you can loop through the array



    For i = 0 to UBound(asObjName)

       set obj = something.VBObject(asObjName(i))

       obj.Click

    Next





    I have not tried this, but if I wanted to do this, I would bark up this tree to start.
  • hi

    thanks for the reply!

    im tring to do it in a different way i have put all the objects names in an excel file then picking up these object with DDT, first im checking either the object exists or not but every time its shows me false value

    myobject.myObjectFromExcelFil.Exists

    error message appears that 'Unable to Find the Object'

    any body any idea?

    -fani
  • sastowe's avatar
    sastowe
    Super Contributor
    myobject.myObjectFromExcelFil.Exists



    That syntax does not look right to me. Are you using short names? Is this what you get for object naming sytax when you record? What it would look like to me in VBScript would be:



    sMyObjectFromExelFil = ... ddt stuff that you clearly get.



    If myObject.WaitVBObject(sMyObjectFromExelFil).Exists then



    ...







  • Hi Fani,



    Please post here your entire script and your Excel file and mark the line that causes the error.
  • hi

    following is my function

    Function mo_ChkParamList( lst_no )    

      ExcelDriverPath1="D:\Perforce\ISCP_Main\Projects\ISCP_Test\Test\CardDesigner_New\ELEMENT_VariousViewerAndEditors\Stores\DB_CardParameterList1.xls"

      Call DDT.ExcelDriver(ExcelDriverPath1,"Sheet1")

      Dim parameterName  

      While Not DDT.CurrentDriver.EOF  

       if DDT.CurrentDriver.Value("tab") <> "" then

            tabName=DDT.CurrentDriver.Value("tab")

           Log.message "#####   TAB '"&tabName&"'   #####"

            Call Aliases.CardDesigner.editors.CardParameter.tab_CardParameter.ClickTab(tabName)        

       end if

        parameterName=DDT.CurrentDriver.Value("Param_name")

        log.message Aliases.CardDesigner.editors.CardParameter.WaitVBObject(parameterName,1000).Exists                                    

          if DDT.CurrentDriver.Value("def_undef"&lst_no)= "visible" and Aliases.CardDesigner.editors.CardParameter.WaitVBObject(parameterName,5000).Exists then

            Log.Event"Correct Status Parameter '"&DDT.CurrentDriver.Value("Parameter")&"' is set to "& DDT.CurrentDriver.Value("def_undef"&lst_no)         

          elseif DDT.CurrentDriver.Value("def_undef"&lst_no)= "invisible" and Not Aliases.CardDesigner.editors.CardParameter.WaitVBObject(parameterName,1000).Exists then

            Log.Event"Parameter '"&DDT.CurrentDriver.Value("Parameter")&"' is set to "& DDT.CurrentDriver.Value("def_undef"&lst_no)

          End if                

      Call  DDT.CurrentDriver.Next()

      WEnd

      DDT.CloseDriver(DDT.CurrentDriver.Name)

     

    End function



    //calling it as follows

    mo_ChkParamList 1



    error line is



    Aliases.CardDesigner.editors.CardParameter.WaitVBObject(parameterName,1000).Exists   

    every time it returns False even when object exists on screen while my object names are mentioned in excel file and i am concatinating it with rest of the mapped name.

    Excel file is attached.

    -farhan