I tried to write an automation test to create a simple J2EE app. However, after I clicked "Finish". A "Open Associated Perspective" message box always popped up. I tried to close it using code below:
bot.button("Finish").click();
bot.sleep(20000);
String oap ="Open Associated Perspective?";
for (SWTBotShell shell : bot.shells()) {
if (shell.getText().equals(oap)) {
shell.activate();
bot.checkBoxWithLabel("Remember my decision").click();
bot.button("Yes").click();
break;
}
}
}catch(WidgetNotFoundException e){
fail("cannot find open associated perspective?"); //for test purpose
}
And it always fail because it cannot find the message box. Actually, I did see the box popped up. Why SWTBot cannot find this shell?
Is the message box native SWT? I ask, because SWTBot can't handle native SWT dialogs like message boxes or file dialogs.
Suggestion: work in your application code with (JFace) MessageDialog.openInformation(....) and not nativ SWT dialogs.
This works fine with SWTBot.