Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsHow to determine button is available or not
https://www.eclipse.org/forums/index.php/mv/msg/235562/716648/#msg_716648
I want to use SWTBot as nightly automation test tool, but i encountered an issue. In our test, for some case a dialog box with 2 buttons will popup, for some case they will not popup, if dialog popups, we need click on a button and continue. Currently i tried to use if(bot.button("Yes").isVisible()) to determine whether there is dialog box or not, but WidgetNotFoundException came up, anyone knows how to handle this case?]]>Joanna 2011-08-18T01:45:39-00:00Re: How to determine button is available or not
https://www.eclipse.org/forums/index.php/mv/msg/235562/718030/#msg_718030
> Hi~
> I want to use SWTBot as nightly automation test tool, but i encountered
> an issue. In our test, for some case a dialog box with 2 buttons will
> popup, for some case they will not popup, if dialog popups, we need
> click on a button and continue. Currently i tried to use
> if(bot.button("Yes").isVisible()) to determine whether there is dialog
> box or not, but WidgetNotFoundException came up, anyone knows how to
> handle this case?
For any dialogs or popup windows that come up, a good way to make sure
they have focus is to perform shell.activate() before performing any
further actions on the shell.
-- Ketan]]>Ketan Padegaonkar2011-08-23T04:46:15-00:00Re: How to determine button is available or not
https://www.eclipse.org/forums/index.php/mv/msg/235562/718118/#msg_718118
If not, i.e. if the dialog randomly pops-up during your tests (weird BTW), then you can try the following:
Iterates on the SWTBot shells to check if one of them is matching the pop-up dialog title. Something like the below code might work:
Quote:
...
String name = ...; // YOUR POP_UP DIALOG'S TITLE
SWTBot bot = ...;
for (SWTBotShell shell : bot.shells()) {
if (shell.getText() != null && shell.getText().equals(name)) {
// HANDLE CASE WHEN DIALOG POPS UP HERE
...
break;
}
...
}
Catch the WidgetNotFoundException and do nothing in the catch block. I am not really in favor of this one as it will delay your test execution, plus you don't know if you enter the catch block because the dialog didn't pop-up or of another reason.
Hope this helps,
]]>Benjamin Ratiarisolo2011-08-23T10:08:40-00:00Re: How to determine button is available or not
https://www.eclipse.org/forums/index.php/mv/msg/235562/721182/#msg_721182
Joanna 2011-09-01T06:38:24-00:00