Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: for the plan.

Jump to: navigation, search

SWTBot/Testing Custom Controls

Update Sites
Mailing List
Open Bugzilla tickets
Open Gerrit reviews
Browse Source
Continuous Integration

Thomas Py wrote: > hI! > i´ve got a rcp-application with own swt-items.. for example there is a "QCombo extends Composite" how can i access this combobox with the swtbot? it´s not a ccombobox and not a combobox so i dont know how can i change the selected item with the swtbot. can swtbot list all widgets? > thnx for any help

Finding the widget is quite easy. Using it is something else...

To find your QCombo widget, do this:

QCombo widget = bot.widget(widgetOfType(QCombo.class));

Now to use it, you can't just do QCombo.setSelectedItem() (or whatever API it might have), you must ensure that the code that needs running in the UI thread be run in the UI thread, using sync or async execution. For some quick testing, you could do this:

asyncExec(new VoidResult(){
   void run(){

but it quickly burdens your test code. What you should do instead is use the page object pattern: make a wrapper for your widget. Ex:

public class SWTBotQCombo extends AbstractSWTBot<QCombo>{
   public SWTBotQCombo(QCombo w) throws WidgetNotFoundException {
      this(w, null);
   public SWTBotQCombo(QCombo w, SelfDescribing description) throws WidgetNotFoundException {
      super(w, description);
   public void setSelectedItem() {
      asyncExec(new VoidResult(){
         void run() {

Hope this helps. -- Pascal Gélinas | Software Developer

  • Nu Echo Inc.* |

  • Because performance matters.*

Back to the top