Using SWTBot to wait for a dialog to display [message #6169] |
Fri, 05 December 2008 18:15  |
Eclipse User |
|
|
|
Hello,
In my trials of using SWTBot I just ran into the first instance where I
need to wait for a particular dialog to appear before continuing with a
test. I searched for some examples of this but didn't find any.
What is the syntax that I should use to wait for a shell with the name
"Configuration" to appear?
Looking at an implementation of shellWithId() I assumed I should do
something similar to the following:
WaitForShell waitForShell =
waitForShell(WidgetMatcherFactory.withText("Configuration"));
bot.waitUntilWidgetAppears(waitForShell);
Without any examples readily available I wanted to verify that this is
the suggested method for waiting for a dialog with a particular title.
Some comments:
- I think what would be extremely valuable to those getting familiar
with SWTBot if some examples of how to find/wait for various SWT
elements were made available.
- providing a SWTBot.shellWithText(String title) method would be useful.
Thanks,
Joe
|
|
|
|
Re: Using SWTBot to wait for a dialog to display [message #7552 is a reply to message #6184] |
Mon, 08 December 2008 12:58   |
Eclipse User |
|
|
|
Ketan Patel wrote:
> I am using version 2.0 and it has following method to wait for shell:
>
> /**
> * @return a wrapper around a @{link Shell} with the specified text.
> * @param text the text on the shell.
> */
> public SWTBotShell shell(String text) {
> return shell(text, 0);
> }
>
> /**
> * @return a wrapper around a {@link Shell} with the specified index.
> * @param text the text on the shell.
> * @param index the index of the shell, in case there are multiple shells
> with the same text.
> */
> public SWTBotShell shell(String text, int index) {
> WaitForShell waitForShell = waitForShell(withText(text));
> waitUntilWidgetAppears(waitForShell);
> return waitForShell.get(index);
> }
>
Thanks, I will try to use the SWTBotFactory.shell() method.
BTW, there is a difference in the APIs that you referenced versus what I
am using. I guess a difference in version 2.0 vs. version 2.0.0.1164?
I am using the latter and have the following APIs
/**
* @return a wrapper around a @{link Shell} with the specified text.
* @param text the text on the shell.
*/
public SWTBotShell shell(String text) {
return shell(text, 0);
}
/**
* @return a wrapper around a {@link Shell} with the specified index.
* @param text the text on the shell.
* @param index the index of the shell, in case there are multiple
shells with the same text.
*/
public SWTBotShell shell(String text, int index) {
return new SWTBotShell(shells(text).get(index));
}
/**
* @return a wrapper around a {@link Shell} with the specified index.
* @param text the text on the shell.
*/
public List<Shell> shells(String text) {
WaitForShell waitForShell = waitForShell(withText(text));
waitUntilWidgetAppears(waitForShell);
ArrayList<Shell> allShells = waitForShell.getAllShells();
return allShells;
}
Thanks,
Joe
|
|
|
|
Powered by
FUDForum. Page generated in 0.03946 seconds