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
>Version: 4.0.0.200910201517
>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: 1.2.1.20090812-1036
>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 {
@Override
protected void setUp() throws Exception {
super.setUp();
IUIContext ui = getUI();
ui.ensureThat(new WorkbenchLocator().hasFocus());
ui.ensureThat(ViewLocator.forName("Welcome").isClosed());
}
/** Issue 1: Auto-completion related */
public void testAutoCompletion() throws Exception {
IUIContext ui = getUI();
// create a sample project
ui.click(new 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");
ui.click(new 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");
ui.click(new ButtonLocator("public static &void main(String[] args)"));
ui.click(new ButtonLocator("&Finish"));
ui.wait(new ShellDisposedCondition("New Java Class"));
ui.click(new CTabItemLocator("Sample.java"));
// XXX move the cursor inside main method via Find n Replace
ui.click(new 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)
ui.click(new ButtonLocator("Fi&nd"));
ui.click(new ButtonLocator("&Replace"));
ui.click(new 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!
autoComplete();
ui.wait(new ShellShowingCondition(""));
ui.click(2, new TableItemLocator("Sample")); // FIXME doesn't work!
ui.enterText(".");
// ui.keyClick(WT.CTRL, ' ');
autoComplete();
ui.wait(new ShellShowingCondition(""));
ui.click(2, new TableItemLocator("class : Class<Sample>"));
ui.enterText(";");
// save the file
ui.click(new MenuItemLocator("File/Save"));
}
protected void autoComplete() throws AWTException {
Robot r = new Robot();
r.keyPress(KeyEvent.VK_CONTROL);
r.keyPress(KeyEvent.VK_SPACE);
r.keyRelease(KeyEvent.VK_SPACE);
r.keyRelease(KeyEvent.VK_CONTROL);
}
}
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.