Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community Forumscan't find button
https://www.eclipse.org/forums/index.php/mv/msg/5483/16476/#msg_16476
This in fact is not a question. I had problem to find a button widget.
I found the solution and want to share it.
Maybe one day it will be usefull for someone.
Problem:
bot.button("xyz") was throwing NotFound exception
... but my "xyz" button was really in the app ...
I noticed that the button in my app was TOGGLE style.
I noticed that the button(string) function was looking only for PUSH style
button.
Therefore it would never find my button.
The solution is to make a matcher with just the string and class
constraints.
Marc]]>Marc2009-01-21T16:52:56-00:00Re: can't find button
https://www.eclipse.org/forums/index.php/mv/msg/5483/16631/#msg_16631
Can you send a piece of your code?]]>Brice Laurel2009-01-22T11:19:54-00:00Re: can't find button
https://www.eclipse.org/forums/index.php/mv/msg/5483/17497/#msg_17497
Here is my code,
it clicks on the 0th button whatever its style.
Matcher matcher = WidgetMatcherFactory.widgetOfType(Button.class);
(new SWTBotButton((Button) bot.widget(matcher, 0))).click();
Here is swtbot.class code that shows the button-style constraint:
public SWTBotButton button(int index) {
Matcher matcher = allOf(widgetOfType(Button.class), withStyle(SWT.PUSH,
"SWT.PUSH"));
return new SWTBotButton((Button) widget(matcher, index));
}
Perhaps the javadoc could mention the SWT.PUSH constraint.