I have a SWT Button, it does not contains text, just an image. I searched for methods, but I can't find a way to press it.
Asked
Active
Viewed 306 times
0
-
Could you please show what you've researched ? – aggietech Jan 13 '16 at 22:43
2 Answers
2
If you know the index -0-based order of the button in all the available buttons in this context- of the button, you can try bot.button(index)
. But as UI can change that, I strongly recommend the solution proposed by @alt3.

Mickael
- 3,506
- 1
- 21
- 33
-
But if you don't have access to the SUT code OR SUT uses some Eclipse built-in controls (i.e. text below the title in the shells. You can set in in the plugin, but you don't have access to the widget itself), than indexes are the only way. – The Godfather May 22 '17 at 15:27
1
Instantiate the button with an id:
yourButton.setData("org.eclipse.swtbot.widget.key", "yourButtonId");
Then, call the following method through the bot:
bot.buttonWithId("yourButtonId").click();

alt3
- 21
- 5