I keep hitting the issue of ui.click (ui.contextClick) stuck. An example case is to click a file item on Project Explorer view. I saw the mouse moved to the item to be clicked, but instead of click, it stuck there. And there is no error or exception. This issue randomly happens to the places where ui.click (or ui.contextClick) is used.
Also, I want to know if there is any way to set timeout to the windowtester test case. I don't want the above issue blocks the other test cases.
public class testUiClick extends UITestCaseSWT {
/**
* Main test method.
*/
public void testmytest() throws Exception {
IUIContext ui = getUI();
//open perspective
ui.click(new MenuItemLocator("Window/Open Perspective/Other..."));
ui.wait(new ShellShowingCondition("Open Perspective"));
ui.click(new TableItemLocator("C/C++(.*)?"));
ui.click(new ButtonLocator("OK"));
ui.wait(new ShellDisposedCondition("Open Perspective"));
//create new project with two files
ui.click(new MenuItemLocator("File/New/Project..."));
ui.wait(new ShellShowingCondition("New Project"));
ui.click(new FilteredTreeItemLocator("Plug-in Project"));
ui.click(new FilteredTreeItemLocator("C++/C++ Project"));
ui.click(new ButtonLocator("&Next >"));
ui.click(new LabeledTextLocator("&Project name:"));
ui.enterText("mytest");
ui.click(new TreeItemLocator("Executable/Hello World C++ Project",
new LabeledLocator(Tree.class, "Toolchains:")));
ui.click(new ButtonLocator("&Next >"));
ui.click(new ButtonLocator("&Next >"));
ui.click(new ButtonLocator("&Finish"));
ui.wait(new ShellDisposedCondition("C++ Project"));
ui.wait(new ShellDisposedCondition("Initialize Indexing"));
ui.click(new TreeItemLocator("mytest/src", new ViewLocator(
"org.eclipse.ui.navigator.ProjectExplorer")));
ui
.contextClick(new TreeItemLocator("mytest/src",
new ViewLocator(
"org.eclipse.ui.navigator.ProjectExplorer")),
"New/Source File");
ui.wait(new ShellShowingCondition("New Source File"));
ui.enterText("mytest2.cpp");
ui.click(new ButtonLocator("&Finish"));
ui.wait(new ShellDisposedCondition("New Source File"));
//test click files
for(int i = 0; i < 20; i++)
{
System.out.println("test: " + i);
System.out.println("click file1");
ui.click(new TreeItemLocator("mytest/src/mytest.cpp", new ViewLocator(
"org.eclipse.ui.navigator.ProjectExplorer")));
ui.pause(1000);
System.out.println("click file2");
ui.click(new TreeItemLocator("mytest/src/mytest2.cpp", new ViewLocator(
"org.eclipse.ui.navigator.ProjectExplorer")));
ui.pause(1000);
}
}
}