You also have Problems with SWTBot right?

Dicle
2 min readOct 20, 2020
Hi! That purple bot is me yes yes, i am SWT Bot created by another purple thing called Eclipse hihi. https://mickaelistria.wordpress.com/2013/10/18/the-face-of-swtbot/

If you are here, you already curious about capabilities of UI testing via SWTBot. Well, i will admit it is not bad or less reliable to use.

But sometimes, it can be a headache.

https://www.someecards.com/

Getting clueless errors about SWTBot? Yeah, i know the feeling.

You can look from here about possible errors you face with. To be honest, they support pretty usefull information here to fix some.

https://wiki.eclipse.org/SWTBot/Troubleshooting

The most common ones -at least the one i was keep facing were about :

  • No active Shell when running SWTBot tests in Xvfb
  • WidgetNotFoundException when stepping through SWTBot test in Eclipse debugger

Another common one is shell activation.

There is some ways to check if your shell is open or not (can save some time to see if you are dealing with the right shell). One of them is :

public static void waitUntilShellIsOpen(SWTBot bot, String text) {
bot.waitUntil(new DefaultCondition() {
@Override
public String getFailureMessage() {
return "Cannot find a shell with text '" + text + "'";
}

@Override
public boolean test() throws Exception {
return bot.shell(text).isOpen();
}
});
}
// Source : https://www.programcreek.com/java-api-examples/?class=org.eclipse.swtbot.swt.finder.SWTBot&method=waitUntil

Apart from that, i will suggest you to have logs enabled for SWTBot especially if you are in plug-in development work.

To do that, you need to create a log4j file. Simply, copy this https://git.eclipse.org/c/swtbot/org.eclipse.swtbot.git/tree/org.eclipse.swtbot.swt.finder.test/src/log4j.xml

into your (E.g. myProject.ui.test) folder.

Then you need to add some plugin support to make it run:

In your plugin’s MANIFEST.MF file:

Require-Bundle: org.eclipse.swtbot.go,
org.apache.log4j
Eclipse-RegisterBuddy: org.apache.log4j

You can run the command below to see if it is really working while testing your SWTBot test classes:

mvn -Dtycho.showEclipseLog=true clean install

Hope all helps! ;)

--

--