Code to choose an item in auto-completion list doesn't work

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

Code to choose an item in auto-completion list doesn't work

Postby har_shan » Tue Mar 30, 2010 10:21 am

Issue #1:
WindowTester generated code to choose an item in auto-completion list doesn't work.
WindowTester tells WidgetNotFound even if it appears to be present.

Machine details:
>Product: WindowTester SWT Professional
>Expected: Eclipse 3.5
>Actual: Eclipse 3.5.0.v20090525
>Actual Eclipse Build Name:
>Actual Eclipse Build ID: M20090917-0800
>IDE Actual Name: Eclipse
>IDE Actual Version:
>OS Name: Windows XP
>OS Architecture: x86
>OS Version: 5.1
>Priority: Standard
>Log Included: No

Code sample:

Code: Select all
public class WindowTesterDoubt extends UITestCaseSWT {

   protected void setUp() throws Exception {
      IUIContext ui = getUI();
      ui.ensureThat(new WorkbenchLocator().hasFocus());
   /** Issue 1: Auto-completion related */
   public void testAutoCompletion() throws Exception {
      IUIContext ui = getUI();

      // create a sample project MenuItemLocator("Window/Open Perspective/Java"));
      ui.contextClick(new SWTWidgetLocator(Tree.class, new ViewLocator(
            "org.eclipse.jdt.ui.PackageExplorer")), "Ne&w/Java Project");
      ui.wait(new ShellShowingCondition("New Java Project"));
      ui.enterText("Test"); ButtonLocator("&Finish"));
      ui.wait(new ShellDisposedCondition("New Java Project"));

      // create a sample class with main()
      ui.contextClick(new TreeItemLocator("Test", new ViewLocator(
            "org.eclipse.jdt.ui.PackageExplorer")), "New/Class");
      ui.wait(new ShellShowingCondition("New Java Class"));
      ui.enterText("Sample"); ButtonLocator("public static &void main(String[] args)")); ButtonLocator("&Finish"));
      ui.wait(new ShellDisposedCondition("New Java Class")); CTabItemLocator(""));

      // XXX move the cursor inside main method via Find n Replace MenuItemLocator("Edit/Find\\\\/Replace..."));
      ui.wait(new ShellShowingCondition("Find/Replace"));
      ui.keyClick(WT.ALT, 'f');
      ui.enterText("// TODO Auto-generated method stub"); // enter find text
      ui.keyClick(WT.ALT, 'e');
      ui.enterText(""); // enter replacement text (empty) ButtonLocator("Fi&nd")); ButtonLocator("&Replace")); ButtonLocator("Close"));
      ui.wait(new ShellDisposedCondition("Find/Replace"));

      // Type 'Class c =' and auto-complete (Ctrl + Space bar) and choose
      // 'Sample', enter '.' and then choose 'class' from auto-completion proposal
      // again
      ui.enterText("Class c = ");
//      ui.keyClick(WT.CTRL, ' '); // FIXME doesn't work!
      ui.wait(new ShellShowingCondition(""));, new TableItemLocator("Sample")); // FIXME doesn't work!
//      ui.keyClick(WT.CTRL, ' ');
      ui.wait(new ShellShowingCondition(""));, new TableItemLocator("class : Class<Sample>"));

      // save the file MenuItemLocator("File/Save"));
   protected void autoComplete() throws AWTException {
      Robot r = new Robot();


Have a look at the FIXME tags in the code, that represents this issue.

I know a workaround of using ARROW keys to choose a value, but i require a more generic solution.

Issue #2:

Am trying to hit Ctrl + Space bar (the key combination that we use for general auto-completion). Am using Java AWT's code as workaround (In attached code see autoComplete() method)

What is the WindowTester WT field to hit SPACE bar key?

Code: Select all
ui.keyClick(WT.CTRL, ???);

Thanks in advance.
Posts: 5
Joined: Tue Mar 30, 2010 10:10 am

Re: Code to choose an item in auto-completion list doesn't work

Postby keertip » Wed Mar 31, 2010 1:54 pm

Issue #1 :
For the auto completion issue, we are sorry to say that as of now we do not have any other generic workaround, apart from using keystrokes to navigate the pop up. The problem here is that the shell that pops up is different and requires special handling, unlike the shells in wizards, dialog etc. This is not there in WindowTester right now and needs to be implemented.

We will add this to our feature request and work towards a solution. Sorry, we do not have an immediate solution.

Issue# 2 :
To press Ctrl + space bar in WindowTester you would use
Code: Select all
ui.keyClick(WT.CTRL, " ");

This code works fine on our end and we are able to see the auto completion dialog after execution of keyClick. Is there anything more you can tell us about your eclipse environment?
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