[Solved] InputDialog - buttons not found [message #509171] |
Thu, 21 January 2010 15:11 |
div Messages: 4 Registered: January 2010 |
Junior Member |
|
|
Hi,
I'm trying to access an input dialog (org.eclipse.jface.dialogs.InputDialog) with SWTBot. But the OK / Cancel buttons are not found. Is the input dialog supported by SWTBot?
What I tried:
bot.button("OK").click();
Exception:
Caused by: org.eclipse.swtbot.swt.finder.widgets.TimeoutException: Timeout after: 5000 ms.: Could not find widget matching: (of type 'Button' and with mnemonic 'OK' and with style 'SWT.PUSH')
I also tried:
SWTBotButton button = new SWTBotButton((Button) bot.widget(withMnemonic("OK")));
button.click();
But that caused the exception:
Caused by: org.eclipse.swtbot.swt.finder.widgets.TimeoutException: Timeout after: 5000 ms.: Could not find widget matching: with mnemonic 'OK'
The InputDialog is invoked like this:
InputDialog x = new InputDialog(parentshell, title, message, initVal, null);
x.open();
(the parentshell is the global shell (IWorkbenchWindow.getShell()))
Any ideas or hints what may be the cause of this?
Thanks!
[Updated on: Mon, 25 January 2010 08:28] Report message to a moderator
|
|
|
Re: InputDialog - buttons not found [message #509265 is a reply to message #509171] |
Thu, 21 January 2010 14:28 |
Pascal G Messages: 157 Registered: July 2009 |
Senior Member |
|
|
div0@gmx.net wrote:
> Hi,
>
> I'm trying to access an input dialog
> (org.eclipse.jface.dialogs.InputDialog) with SWTBot. But the OK / Cancel
> buttons are not found. Is the input dialog supported by SWTBot?
>
> What I tried:
> bot.button("OK").click();
>
> Exception:
> Caused by: org.eclipse.swtbot.swt.finder.widgets.TimeoutException:
> Timeout after: 5000 ms.: Could not find widget matching: (of type
> 'Button' and with mnemonic 'OK' and with style 'SWT.PUSH')
>
>
> I also tried:
> SWTBotButton button = new SWTBotButton((Button)
> bot.widget(withMnemonic("OK"))); button.click();
>
> But that caused the exception: Caused by:
> org.eclipse.swtbot.swt.finder.widgets.TimeoutException: Timeout after:
> 5000 ms.: Could not find widget matching: with mnemonic 'OK'
>
>
> The InputDialog is invoked like this:
>
> InputDialog x = new InputDialog(parentshell, title, message, initVal,
> null);
> x.open();
> (the parentshell is the global shell (IWorkbenchWindow.getShell()))
>
> Any ideas or hints what may be the cause of this?
> Thanks!
>
I do think they are supported, since they are not native dialog. It's
only a custom made shell with some widget in it. Are you sure that the
button's label is "OK"? I'd try "Ok" just to be sure; I think the 'K'
should be lower-case. If that doesn't solve the problem, I'd try this to
see if you get a WidgetNotFound:
SWTBotShell shell = bot.shell(title);
if this fails, then its probably that your input dialog is not open. If
this doesn't fail, I'd do this:
bot.widget(allOf(widgetOfType(Button.class), withMnemonic("OK")));
Then again, if you try this make sure you have the good mnemonic. If
this doesn't work... well it should work :P
Hope this helps.
--
Pascal Gélinas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/
*Because performance matters.*
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.25312 seconds