Search code examples
user-interfaceswtgui-testingswtbot

Handling SWT Dialog boxes while running tests in headless mode using SWTBOT


I am running a Junit test case on my eclipse application that was built using SWT. I am doing GUI testing using SWTBot. So, here is my problem:

editor.bot().button("Make Excel Template").click();

This code helps me generate a template in my application. Once done, it throws up a Modal Dialog with "OK" as a message. However, I can't get SWTBot to find this button/widget/dialog box. I keep getting a 'WidgetNotFoundException'.

Has someone come across this? official content on the SWTBot website says that dialog boxes should be run in seperate non-UI threads. The examples provided however, aren't very informative.

Appreciate your help!


Solution

  • @carstenlez - your solution works well for JFace Dialog boxes. My app, however, is making use of a MessageBox - which is a native dialog. SWTBot doesn't support native dialogs, so I am pretty much out of options.