Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 356883 - SWTBot seems not to find a combo box in the toolbar.
Summary: SWTBot seems not to find a combo box in the toolbar.
Status: RESOLVED FIXED
Alias: None
Product: SWTBot
Classification: Technology
Component: EclipseBot (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows Vista
: P3 normal (vote)
Target Milestone: 2.2.0   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-06 23:36 EDT by Madhu G CLA
Modified: 2013-12-20 07:02 EST (History)
4 users (show)

See Also:


Attachments
Dropdown in view (54.91 KB, image/png)
2011-11-13 12:59 EST, Ketan Padegaonkar CLA
no flags Details
ZoomControlOntheToolBar (6.44 KB, image/png)
2011-11-14 23:39 EST, Madhu G CLA
no flags Details
Added ToolItemResolver (2.51 KB, patch)
2013-10-11 08:57 EDT, Marcel Hoetter CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Madhu G CLA 2011-09-06 23:36:23 EDT
Build Identifier: 3.5.2

HI,

The issue details are already posted in the eclipse forum :
Please visit Forum :
<http://www.eclipse.org/forums/index.php/mv/msg/220874/697096/#msg_697096>

Issue excerpt:

I am trying to test an eclipse RCP application. I want SWTBot to click 
on an item of a combo box (drop down box), which is located in the 
toolbar of a view. This combo box is created in my class myOptionsCombo 
and contributed as control for a menuContribution 
("toolbar:com...gui.myView (menuContribution)" ).

In class myOptionsCombo, I called setToolTip() and setData()
> Combo combo = new Combo(parent, SWT.DROP_DOWN);
> combo.setToolTip("aToolTip");
> combo.setData("name", "myCombo");
> // adding my items...
to get more options to find it with SWTBot.

The toolbar contains other elements (toolbar buttons) which have been 
defined in code (no contributions). I am able to click these buttons.

But accessing my combo box never worked so far:

But when calling
> SWTWorkbenBot bot = new SWTWorkbenBot();
> SWTBotView viewBot = bot.viewById("myView");
> viewBot.setFocus();
> viewBot.toolbarButton("Tooltip of a button").click(); // this worked
> SWTBotCCombo combo = viewBot.bot().comboboxWithId ("name", "myCombo");
I get a WidgetNotFoundException.

Can someone show me how to access the combo and click one of its items ?

Best regards,
Madhu

Reproducible: Always

Steps to Reproduce:
1.Assuming combo presents in the toolbar.
2.Not able to identify the widget using SWTBot toolbarDropDownButtonWithTooltip 
Details :
<http://www.eclipse.org/forums/index.php/mv/msg/220874/697096/#msg_697096>
Comment 1 Ketan Padegaonkar CLA 2011-11-13 12:59:24 EST
Created attachment 206902 [details]
Dropdown in view
Comment 2 Ketan Padegaonkar CLA 2011-11-13 13:00:58 EST
I've looked at this issue and I'm able to click on a drop down button inside the toolbar using the following api.

  bot.viewByTitle('Task List').toolbarDropDownButton('New Task').click()

See the screenshot of which drop down I'm referring to.

Do you have a screenshot of how your dropdown looks like and the output of the spy view when spying on your dropdown (http://wiki.eclipse.org/SWTBot/FAQ#Can_I_get_more_details_on_a_particular_widget.3F)
Comment 3 Madhu G CLA 2011-11-14 23:31:17 EST
HI ,


I am attaching the combo box snapshot. Please have a look on this.


Thanks & regards,
Madhu
Comment 4 Madhu G CLA 2011-11-14 23:39:00 EST
Created attachment 207001 [details]
ZoomControlOntheToolBar

Zoom Control Combo box on the tool bar.
Comment 5 Madhu G CLA 2011-11-14 23:54:36 EST
(In reply to comment #4)
> Created attachment 207001 [details]
> ZoomControlOntheToolBar
> 
> Zoom Control Combo box on the tool bar.

Adding captured details by Spy view:
To toggle, or freeze info on a particular control, press CTRL+SHIFT: 


Location: 
//Shell/-1//CBanner/0//Composite/0//CoolBar/0//ToolBar/11//Combo/0

Layout Information: 
Combo {150%}
	Style: DROP_DOWN | READ_ONLY | HORIZONTAL | LEFT_TO_RIGHT 
	Layout Data: null
	Bounds: Rectangle {46, 0, 75, 23}


Children: 0

Siblings: 1
	[*]Combo {150%}: Layout Data: null

Parent Tree:
ToolBar {}[11]@
	 Layout: null
	 LayoutData: null
	CoolBar {}[0]@
		 Layout: null
		 LayoutData: null
		Composite {}[0]@
			 Layout: CacheWrapper$WrapperLayout
			 LayoutData: CLayoutData
			CBanner {}[0]@
				 Layout: CBannerLayout
				 LayoutData: WindowTrimProxy
				Shell {Business Blueprint -...}[-1]@
					 Layout: TrimLayout
					 LayoutData: null
Comment 6 Geoff Bache CLA 2013-04-16 11:11:09 EDT
Just got bitten by this too. Note that Ketan's example above is using a drop-down button, which is not at all the same thing as a combo box attached to a separator.

Looking in ToolbarResolver, I'm guessing getChildren might need to do getControl on each of the items and add any controls it finds to the list. I'm trying to access it by using the ControlFinder, which doesn't find it.
Comment 7 Marcel Hoetter CLA 2013-10-11 08:53:14 EDT
Hello,

i had a similar problem: SWTBot did not find a Text control contribution added via the org.eclipse.ui.menus extension point to the main toolbar of an RCP application.

After some debugging, i found that SWTBot is missing a suitable Resolver for ToolItems. I implemented the Resolver and modified the SWTBot finder to include it in it's search.

I will attach a patch with the changes.
Comment 8 Marcel Hoetter CLA 2013-10-11 08:57:29 EDT
Created attachment 236370 [details]
Added ToolItemResolver

Added ToolItemResolver and modified finders so SWTBot finds control contributions added to the a RCP main or view toolbar via the org.eclipse.ui.main.toolbar extension point.
Comment 9 Mickael Istria CLA 2013-10-11 09:01:56 EDT
Thanks for this patch Marcel. Can you please ocntribute it using Gerrit as explained on http://wiki.eclipse.org/SWTBot/Contributing . It will make review easier.
Comment 10 Mickael Istria CLA 2013-10-15 04:18:32 EDT
Thanks @Marcel for contrib https://git.eclipse.org/r/#/c/17313/