Application losing focus

WindowTester allows you to easily create and run unit tests for every GUI they build. It can also be used to generate system level tests.

Moderators: gnebling, Eric Clayberg, Dan Rubel, keertip, Phil Quitslund

Application losing focus

Postby peter.blomberg » Fri Oct 01, 2010 5:30 am

I have a problem when trying out the demo application and recording a simple test.
After a few operations, adding a contact I try to click the "File" menu but by then the application has lost focus and the mouse is located in the top left corner of my other screen!

Here is the test code:
Code: Select all
   public void testTest3() throws Exception {
      IUIContext ui = getUI();
      ui.click(new MenuItemLocator("File/New Contact..."));
      ui.wait(new ShellShowingCondition(""));
      ui.click(new LabeledTextLocator("First Name"));
      ui.enterText("Kalle");
      ui.keyClick(WT.TAB);
      ui.enterText("Anka");
      ui.keyClick(WT.TAB);
      ui.click(new ButtonLocator("&Finish"));
      ui.click(new MenuItemLocator("File/New Contact..."));
      ui.wait(new ShellShowingCondition(""));
      ui.click(new LabeledTextLocator("First Name"));
      ui.enterText("Musse");
      ui.click(new LabeledTextLocator("Last Name"));
      ui.enterText("Pigg");
      ui.click(new LabeledTextLocator("Street"));
      ui.click(new ButtonLocator("&Finish"));
      
      TableItemLocator tableItemLocator = new TableItemLocator("Anka,Kalle", new ViewLocator("rcpContactMngr.view"));
      ui.click(tableItemLocator);
      
      ui.ensureThat(new ShellLocator("RCP Contacts Editor").hasFocus());
      ui.click(new MenuItemLocator("File/Exit"));

   }


What can i be doing wrong?

Regards
Peter

I have a dual screen setup on a Windows XP (64-bit) pc
peter.blomberg
 
Posts: 2
Joined: Fri Oct 01, 2010 1:04 am

Re: Application losing focus

Postby keertip » Fri Oct 01, 2010 10:10 am

Add a

Code: Select all
ui.ensureThat(new ShellLocator("RCP Contacts Editor").hasFocus());


before the second

Code: Select all
ui.click(new MenuItemLocator("File/New Contact..."));


and see if it solves the problem.
keertip
Moderator
 
Posts: 221
Joined: Thu Mar 15, 2007 10:26 am

Re: Application losing focus

Postby peter.blomberg » Sun Oct 03, 2010 11:53 pm

Tried that, no difference.

I tried to remove the line "ui.click(tableItemLocator);" and now the test passes!
Any ideas why that line makes the application lose focus?

I found that by adding
Code: Select all
      ui.ensureThat(new WorkbenchLocator().hasFocus());

before
Code: Select all
      ui.ensureThat(new ShellLocator("RCP Contacts Editor").hasFocus());

the test passes.

This looks wrong to me!

Peter
peter.blomberg
 
Posts: 2
Joined: Fri Oct 01, 2010 1:04 am

Re: Application losing focus

Postby keertip » Mon Oct 04, 2010 10:14 am

We don't see the application losing focus while running the test code that you posted (no modifications) - test passes. So maybe this problem has to do with the dual monitors.
keertip
Moderator
 
Posts: 221
Joined: Thu Mar 15, 2007 10:26 am


Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest

cron