Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » SWTBotTreeItem#select() is not working as it should?
SWTBotTreeItem#select() is not working as it should? [message #805165] Thu, 23 February 2012 07:19 Go to next message
Rüdiger Herrmann is currently offline Rüdiger Herrmann
Messages: 335
Registered: July 2009
Senior Member
Hi,

I found SWTBotTreeItem#select() to not work as I would expect.
With a tree like this:
+ project
|- file
where the 'project' item is initially collapsed.

This code snippet doesn't select the 'file' item:
tree.expandNode( "project" );
SWTBotTreeItem fileItem = projectItem.select( "file" );
assertEquals( "file", fileItem.getText() );
After it is executed, the projectItem is expanded and selected, hence
the assertion fails with: expected 'file' but was 'project'.

Where as this code succeeds in selecting the 'file' item:
SWTBotTreeItem projectItem = tree.expandNode( "project" );
SWTBotTreeItem fileItem = projectItem.getNode( "file" ).select();
assertEquals( "file", fileItem.getText() );

Is this a bug? Am I missing something?

Thanks in advance,
Rüdiger Herrmann
Re: SWTBotTreeItem#select() is not working as it should? [message #821313 is a reply to message #805165] Thu, 15 March 2012 03:31 Go to previous message
benhu Missing name is currently offline benhu Missing name
Messages: 14
Registered: October 2010
Junior Member

Hi,
I donot think this is a bug.
In my opinion,

what【projectItem.select( "file" );】selects is a TreeItem with the name "file", but the node "file" itself isn't selected.
so, you should make the node is selected first, then use tree.select(...) to select the node(s), and return as TreeItem.

hope this can help you.
Previous Topic:Issue in waiting for tree expansion
Next Topic:Drag&Drop SWTBotTreeItem to SWTBotGefEditor
Goto Forum:
  


Current Time: Thu Jul 24 21:35:38 EDT 2014

Powered by FUDForum. Page generated in 0.01486 seconds