开发者

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

开发者 https://www.devze.com 2022-12-14 14:17 出处:网络
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:

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!


First you should run your tests in a non-UI-Thread (if not already doing so). Second you can use a condition to wait for your modal dialog to appear after executing the action that will bring the dialog up:

bot.waitUntil(Conditions.shellIsActive("This is the title of the modal dialog "));
bot.button("OK").click();

This solved our timing issues.


@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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号