Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » SWTBot has different behaviour depending if the window is top-most or not
SWTBot has different behaviour depending if the window is top-most or not [message #559347] Thu, 16 September 2010 12:57 Go to next message
Gabriel Petrovay is currently offline Gabriel Petrovay
Messages: 42
Registered: July 2009
Member
Hi Ketan,

I have a test suite that when I start by hand from Eclipse runs successfully. But when I run it from a task (Windows' Task Scheduler) the some tests constantly fail.

One such problem is because the Window is not top-most when started from the Task Scheduler. To simplify this, this test also fails if you start it from Eclipse and you make another windows top-most such that the Eclipse SWTBot starts is not any more the top-most one.

The test fails because of the timeout waiting for a shell to be active:

bot.waitUntil(Conditions.shellIsActive("Errors in Workspace"));

But since the focus is on another window, the shell will never be active (having focus).

Consider that you have all these pop-ups in Eclipse like "Do you want to open the associated perspective?", "Save file", "Errors in Workspace", etc. that tou want to close. Do you know ways to work around this "sleep until active" condition? More precisely, to make the tests independent of whether the window is top most or not.

I can not control how the Eclipse application started (top-most or not). In my scenario Task Scheduler calls a batch script. This calls the ant batch script available in the eclipse/plugins/org.apache.ant.../bin. And this loads the tests.xml ant script that contains the target as described on the page http://wiki.eclipse.org/SWTBot/Ant#Ant .


Regards,
Gabriel
Re: SWTBot has different behaviour depending if the window is top-most or not [message #560422 is a reply to message #559347] Tue, 21 September 2010 15:11 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan Padegaonkar
Messages: 873
Registered: July 2009
Senior Member
If I understand correctly, the problem is that the eclipse window is not
the window on top causing tests to fail. One way to fix this is to force
focus when the tests run in headless mode.

class AllTests {
static {
bot.shell('window title').setFocus();
}
}

I've also noticed at times that this does not actually force focus on
the window, but rather alerts the user via a blinking taskbar that the
window needs attention. There's always autoit
(http://www.autoitscript.com/autoit3/index.shtml) for such those weird
windows 'features'.

--
Ketan
http://ketan.padegaonkar.name | http://eclipse.org/swtbot

On 9/16/10 5:57 AM, Gabriel Petrovay wrote:
> Hi Ketan,
>
> I have a test suite that when I start by hand from Eclipse runs
> successfully. But when I run it from a task (Windows' Task Scheduler)
> the some tests constantly fail.
>
> One such problem is because the Window is not top-most when started from
> the Task Scheduler. To simplify this, this test also fails if you start
> it from Eclipse and you make another windows top-most such that the
> Eclipse SWTBot starts is not any more the top-most one.
>
> The test fails because of the timeout waiting for a shell to be active:
>
> bot.waitUntil(Conditions.shellIsActive("Errors in Workspace"));
>
> But since the focus is on another window, the shell will never be active
> (having focus).
>
> Consider that you have all these pop-ups in Eclipse like "Do you want to
> open the associated perspective?", "Save file", "Errors in Workspace",
> etc. that tou want to close. Do you know ways to work around this "sleep
> until active" condition? More precisely, to make the tests independent
> of whether the window is top most or not.
>
> I can not control how the Eclipse application started (top-most or not).
> In my scenario Task Scheduler calls a batch script. This calls the ant
> batch script available in the eclipse/plugins/org.apache.ant.../bin. And
> this loads the tests.xml ant script that contains the target as
> described on the page http://wiki.eclipse.org/SWTBot/Ant#Ant .
>
>
> Regards,
> Gabriel
Re: SWTBot has different behaviour depending if the window is top-most or not [message #623619 is a reply to message #559347] Wed, 22 September 2010 02:26 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan Padegaonkar
Messages: 873
Registered: July 2009
Senior Member
If I understand correctly, the problem is that the eclipse window is not
the window on top causing tests to fail. One way to fix this is to force
focus when the tests run in headless mode.

class AllTests {
static {
bot.shell('window title').setFocus();
}
}

I've also noticed at times that this does not actually force focus on
the window, but rather alerts the user via a blinking taskbar that the
window needs attention. There's always autoit
(http://www.autoitscript.com/autoit3/index.shtml) for such those weird
windows 'features'.

--
Ketan
http://ketan.padegaonkar.name | http://eclipse.org/swtbot

On 9/16/10 5:57 AM, Gabriel Petrovay wrote:
> Hi Ketan,
>
> I have a test suite that when I start by hand from Eclipse runs
> successfully. But when I run it from a task (Windows' Task Scheduler)
> the some tests constantly fail.
>
> One such problem is because the Window is not top-most when started from
> the Task Scheduler. To simplify this, this test also fails if you start
> it from Eclipse and you make another windows top-most such that the
> Eclipse SWTBot starts is not any more the top-most one.
>
> The test fails because of the timeout waiting for a shell to be active:
>
> bot.waitUntil(Conditions.shellIsActive("Errors in Workspace"));
>
> But since the focus is on another window, the shell will never be active
> (having focus).
>
> Consider that you have all these pop-ups in Eclipse like "Do you want to
> open the associated perspective?", "Save file", "Errors in Workspace",
> etc. that tou want to close. Do you know ways to work around this "sleep
> until active" condition? More precisely, to make the tests independent
> of whether the window is top most or not.
>
> I can not control how the Eclipse application started (top-most or not).
> In my scenario Task Scheduler calls a batch script. This calls the ant
> batch script available in the eclipse/plugins/org.apache.ant.../bin. And
> this loads the tests.xml ant script that contains the target as
> described on the page http://wiki.eclipse.org/SWTBot/Ant#Ant .
>
>
> Regards,
> Gabriel
Re: SWTBot has different behaviour depending if the window is top-most or not [message #628173 is a reply to message #623619] Thu, 23 September 2010 09:52 Go to previous message
Gabriel Petrovay is currently offline Gabriel Petrovay
Messages: 42
Registered: July 2009
Member
Hi Ketan,

The hint you gave me does not help. On Windows 7, that I am using for testing, it doesn't bring the window topmost.

I tried:

static {
bot.shell("title").setFocus();
bot.shell("title").activate();
bot.shell("title").click();
}

I only managed to bring it topmost in a very weird way. When the main shell has a modal dialog window opened (like New Project Wizard) and I press a shortcut of a TextField and then setFocus on the text control:

SWTBotShell projectShell = bot.shell("...");
projectShell.pressShortcut(SWT.ALT, 'p');
SWTBotText text = bot.textWithLabel("Project name:").setText("My project name");
text.setFocus();

This is the only case I saw that the window is always brought to the front.

Any other things I could try (in the code)?

Thnks!





Previous Topic:Searching Trees
Next Topic:After click a MenuItem of a toolbarDropDownButton, the MenuItem is still displayed in the screen
Goto Forum:
  


Current Time: Thu Oct 02 14:40:48 GMT 2014

Powered by FUDForum. Page generated in 0.02802 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software