cancel
Showing results for 
Search instead for 
Did you mean: 

Find Child Loop Statement

SOLVED
Highlighted
Contributor

Find Child Loop Statement

Hey Guys,

 

I'm stuck on a pretty interesting problem and I was wondering if you could help me out. I basically think I'm having a syntax issue with the findchild statement. 

 

I want to create a for  loop that will click each button in a toolbar. The buttons are identified with this "Name" property: 

SwingObject("MJButton", "", 1)

then the next button is:

SwingObject("MJButton", "", 2)

 

Each button is incremented by 1. With this in mind, I want to put together a for loop:

 

for(var i=1;i<=numberOfChildren;i++)
{
   var Btn = toolBar.FindChild('Name', 'SwingObject("MJButton", "", i)', 2)
   Sys.HighlightObject(Btn,3)
}

 

And this is where I'm stuck. Because I have "i" declared in a string, its not being seen as a increment so nothing happens when the statement is executed. Reading the FindChild documentation and examples, it seems like object properties have  to be declared as strings. 

 

is there a correct way to write the 'SwingObject("MJButton", "", i)' statement? 

 

Much appreciated ! 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: Find Child Loop Statement

Hi,

 

var Btn = toolBar.FindChild('Name', aqString.Format('SwingObject("MJButton", "", %i)', i), 2)

Does this help?

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

3 REPLIES 3
Highlighted
Community Hero

Re: Find Child Loop Statement

Hi,

 

var Btn = toolBar.FindChild('Name', aqString.Format('SwingObject("MJButton", "", %i)', i), 2)

Does this help?

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

Highlighted
Contributor

Re: Find Child Loop Statement

Hi,

 

Thank you! that worked! 

 

I'm a little confused on why it worked though. By using the aqFile format, we were able to subsitute a variable into a string? 

 

Thanks again! 

Highlighted
Community Hero

Re: Find Child Loop Statement

Hi,

 

we were able to subsitute a variable into a string?

Yes, correct.

Basically,

aqString.Format('SwingObject("MJButton", "", %i)', i)

is equivalent to

'SwingObject("MJButton", "", ' + i + ')'

 

Use whatever of them is more clear for you.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors