windowtester click all buttons with the same name

138 Views Asked by At

I'm using window tester and I have a wizard with three buttons with the same text: "Select all". If there is only one button, I do ui.click(new JButtonLocator("Select all"));

with three, I was trying to use IWidgetLocator[] allSelectAll = ui.findAll(new JButtonLocator("Select all")); and then use the IWidgetLocator to click one or all of them. How can I do that?

thanks.

1

There are 1 best solutions below

0
On

You can use the following constructor for this:

JButtonLocator(String label, int index, SwingWidgetLocator parent)

Specify the index (zero-based) and the parent widget (eg. JFrame):

ui.click(new JButtonLocator("Select all", 0, new SwingWidgetLocator(JFrame.class)));

This should let you click on the first of the "Select all" buttons. Just change the index to do the same for the other buttons.

HTH