Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » cannot find Package Explorer if just import a project but okay after creating a new project
cannot find Package Explorer if just import a project but okay after creating a new project [message #682385] Sat, 11 June 2011 00:58 Go to next message
Joanna  is currently offline Joanna Friend
Messages: 12
Registered: May 2011
Junior Member
Hi!
I am tring to apply SWTBot as our GUI automation test tool, it's very easy to get started, but i encounter a problem. I just import a project, and want to select right-click menu and do something. i used following code to select right-click menu:

SWTBotView view = bot.viewByTitle("Package Explorer");
List controls = new ChildrenControlFinder(view.getWidget()).findControls(WidgetOfType.widgetOfType(Tree.class));
if (controls.isEmpty())
fail("Tree in Package Explorer View was not found.");
SWTBotTree tree = new SWTBotTree((Tree) controls.get(0));

SWTBotTreeItem item = tree.getTreeItem("AndroidPdfViewer");
if(item == null){
throw new WidgetNotFoundException("Could not find menu: test");
}
item.setFocus();

but Package Explorer cannot be found with error

org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException: Could not find widget.
at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntilWidgetAppears(SWTBotFactory.java:348)
at org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot.view(SWTWorkbenchBot.java:128)
at org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot.viewByTitle(SWTWorkbenchBot.java:141)
at MyFirstTestCase.convertKona(MyFirstTestCase.java:240)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner.run(SWTBotJunit4ClassRunner.java:54)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.swtbot.eclipse.core.RemotePluginTestRunner.main(RemotePluginTestRunner.java:64)
at org.eclipse.swtbot.eclipse.core.UITestApplication.runTests(UITestApplication.java:117)
at org.eclipse.ui.internal.testing.WorkbenchTestable$1.run(WorkbenchTestable.java:71)
at java.lang.Thread.run(Unknown Source)
Caused by: org.eclipse.swtbot.swt.finder.widgets.TimeoutException: Timeout after: 5000 ms.: Could not find view matching: with name '"Package Explorer"'
at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:398)
at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:372)
at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:360)
at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntilWidgetAppears(SWTBotFactory.java:346)
... 31 more


But if i add create a new project test, try the test above then it's okay, i have no idea about what's going on. Do i use it in a wrong way? or i need update something?
Re: cannot find Package Explorer if just import a project but okay after creating a new project [message #687815 is a reply to message #682385] Thu, 23 June 2011 09:53 Go to previous messageGo to next message
Benjamin Ratiarisolo is currently offline Benjamin RatiarisoloFriend
Messages: 16
Registered: January 2010
Location: Paris, France
Junior Member
Hi Joanna,

Are you sure that the Package Explorer view is indeed displayed when calling 'SWTBotView view = bot.viewByTitle("Package Explorer");'?
If not you'll have to either switch to the appropriate (Java?) perspective or explicitly show the Package Explorer view through SWTBot API.
When you creating a new project, eclipse may automatically switch to the Java perspective (depending on your preferences perhaps), which would explain the symptoms you describe.


--
Benjamin Ratiarisolo
IBM ODM Decision Server Rules - Software Developer
IBM Software - France Lab
Re: cannot find Package Explorer if just import a project but okay after creating a new project [message #689168 is a reply to message #687815] Mon, 27 June 2011 03:28 Go to previous messageGo to next message
Joanna  is currently offline Joanna Friend
Messages: 12
Registered: May 2011
Junior Member
Hi,Benjamin~
Thanks for your reply, i tried again and found like you mentioned, if import project only, package explorer didn't activate, but project explorer activated, so after changing SWTBotView view = bot.viewByTitle("Package Explorer") to SWTBotView view = bot.viewByTitle("Project Explorer"), it works well. I found during my test, lots of errors are caused due to wrong title usage. I didn't have eclipse and SWTBot experience before, is there any better way to avoid the title related errors, or any documents reference?
Re: cannot find Package Explorer if just import a project but okay after creating a new project [message #690340 is a reply to message #689168] Wed, 29 June 2011 11:54 Go to previous messageGo to next message
Benjamin Ratiarisolo is currently offline Benjamin RatiarisoloFriend
Messages: 16
Registered: January 2010
Location: Paris, France
Junior Member
Hi Joanna,

I usually try to access the labels directly from the eclipse plug-ins that define them (either in a messages.properties file or plugin.properties file). Note that some labels are also available through final static String constants (example: org.eclipse.ui.internal.ide.IDEWorkbenchMessages.OpenWorkspaceAction_other in org.eclipse.ui.ide plugin).

For instance:
* "Package Explorer" is defined by the property key "packagesViewName" in the org.eclipse.jdt.ui plugin.properties file.
* "Project Explorer" is defined by the property key "Common_Resource_Navigator" in the org.eclipse.ui.navigator.resources plugin.properties file.

However some of those keys are very hard to find: you may spend quite a lot of time browsing the eclipse plug-ins before finally finding the one(s) you are looking for.

Proper handling of those properties also helps globalizing your SWTBot test cases (i.e run them on different locales).

Cheers,


--
Benjamin Ratiarisolo
IBM ODM Decision Server Rules - Software Developer
IBM Software - France Lab
Re: cannot find Package Explorer if just import a project but okay after creating a new project [message #690751 is a reply to message #690340] Thu, 30 June 2011 07:06 Go to previous message
Joanna  is currently offline Joanna Friend
Messages: 12
Registered: May 2011
Junior Member
Hi, Benjamin:

Thank you so much for the sharing Smile, and it's nice to know so many people are working with SWTBot. I will spend more time on it. Thanks again~~
Previous Topic:How to Wait until the editor opens
Next Topic:How to restart RCP application for each case?
Goto Forum:
  


Current Time: Tue Apr 16 19:06:33 GMT 2024

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

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

Back to the top