Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » can't find button
can't find button [message #16476] Wed, 21 January 2009 16:52 Go to next message
Marc is currently offline MarcFriend
Messages: 32
Registered: July 2009
Member
Hi,

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
Re: can't find button [message #16631 is a reply to message #16476] Thu, 22 January 2009 11:19 Go to previous messageGo to next message
Brice Laurel is currently offline Brice LaurelFriend
Messages: 72
Registered: July 2009
Member
Thanks Marc,

Can you send a piece of your code?
Re: can't find button [message #17497 is a reply to message #16631] Thu, 22 January 2009 14:07 Go to previous message
Marc is currently offline MarcFriend
Messages: 32
Registered: July 2009
Member
Hi,

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.

Bye
Marc
Previous Topic:Eclipse doesn't show launcher configuration "SWTBot Test"
Next Topic:press enter in a table
Goto Forum:
  


Current Time: Sat Jul 27 10:12:14 GMT 2024

Powered by FUDForum. Page generated in 0.04109 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top