Forum Discussion

rushikesh's avatar
rushikesh
Contributor
6 years ago

How to get only checkbox control using FindAllChildren

Hi,

 

I have a dialog on which i want to check all the checkbox. Refer attached image dialog.png.

 

I use below code.

function checkbox()
  {
    var i, buttons;
   
    page = Aliases.SLDWORKS.dlgTBM.page32770
    buttons = page.FindAllChildren("WndClass", "Button", 5);
    
  if (buttons.length > 0)
  {
    for (let i = 0; i < buttons.length; i++)
      {
      Log.Message("FullName: " + buttons[i].FullName );
      if(buttons[i].Visible)
      buttons[i].ClickButton(1)
      }
    Log.Message("Total number of found edit buttons: " + buttons.length);
  }
  else
    Log.Warning("No buttons found.");
 
  }

 

I able to find all checkboxes prsent in dialog.

Problem is there is a option group box. Refer image Dialog.png.

This group box is also included in Buttons and Test Complete tries to check this button, giving error.

 

How to avoid this ?

 

3 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    Put a conditional inside your for loop.  I don't know your syntax but it will look like this:

     

    if (button name <> "Options") then

      {do all the other stuff here}

    • rushikesh's avatar
      rushikesh
      Contributor

      Marsha_R :  Yes, it will work.

      But, I will be running test in languages other than English in which caption of group box will change from "Option" to something else.

       

      Is there a way to know that object is a checkbox ?

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        So the Group Box has a WndClass of "Button"?  That seems REALLY weird to me.  What I would do is examine that a bit more closely and see if there are other properties that might filter out the group box.  FindAllChildren allows you to send in an Array of properties and a corresponding Array of desired values.  So, you're not limited to just WndClass.  Narrow your FindAllChildren search to include some other properties so the "Options" box does not appear.