Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Using DropDownButton(DropDownButton with MenuItems)
Using DropDownButton [message #502619] Wed, 09 December 2009 08:03 Go to next message
Tim  is currently offline Tim Friend
Messages: 12
Registered: December 2009
Junior Member
I have problems with my dropdownbuttons,
if i use it the first time, it works. But the second time, it does not work. i get the exception "could not find widget".

I have stopped the bot at the second time and see, the menu of the button is always open ...

My Code:
bot = new SWTWorkbenchBot();
bot.toolbarDropDownButton("AddButton").menuItem("button1").click();
assertEquals(check.some.thing);
bot.toolbarDropDownButton("AddButton").menuItem("button2").click();


The first click on "button 1" works, but the second one not. Why?
Re: Using DropDownButton [message #502698 is a reply to message #502619] Wed, 09 December 2009 13:23 Go to previous messageGo to next message
Pascal G is currently offline Pascal GFriend
Messages: 157
Registered: July 2009
Senior Member
Tim wrote:
> I have problems with my dropdownbuttons,
> if i use it the first time, it works. But the second time, it does not
> work. i get the exception "could not find widget".
>
> I have stopped the bot at the second time and see, the menu of the
> button is always open ...
>
> My Code:
> bot = new SWTWorkbenchBot();
> bot.toolbarDropDownButton("AddButton").menuItem("button1").click();
> assertEquals(check.some.thing);
> bot.toolbarDropDownButton("AddButton").menuItem("button2").click();
>
>
> The first click on "button 1" works, but the second one not. Why?

If you try the following snippet, where does it fails and what is the
exception/error?
SWTBotToolbarDropDownButton button = bot.toolbarDropDownButton("AddButton");
SWTBotMenu menuItem = button.menuItem("button2");
menuItem.click();

--
Pascal Gélinas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/

*Because performance matters.*
Re: Using DropDownButton [message #502770 is a reply to message #502698] Wed, 09 December 2009 16:31 Go to previous messageGo to next message
Tim  is currently offline Tim Friend
Messages: 12
Registered: December 2009
Junior Member
I have tried your code. It fails on the following line:
SWTBotMenu menuItem = button.menuItem("Button2");


With the Exception-Text:
Quote:

org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundExcep tion: Could not find a menu item
at org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownB utton.toSWTBotMenuItems(SWTBotToolbarDropDownButton.java:153 )
at org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownB utton.menuItems(SWTBotToolbarDropDownButton.java:127)
at org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownB utton.menuItem(SWTBotToolbarDropDownButton.java:94)
at org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownB utton.menuItem(SWTBotToolbarDropDownButton.java:81)

Re: Using DropDownButton [message #536221 is a reply to message #502770] Thu, 27 May 2010 12:31 Go to previous messageGo to next message
Stuart Barker is currently offline Stuart BarkerFriend
Messages: 1
Registered: May 2010
Junior Member
We have this problem too. Has been reported as a bug on Cocoa but I think it applies to other platforms as well.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=308736

Clicking doesn't dismiss the menu. We've had to insert an escape keystroke after the click to force it to go.
Re: Using DropDownButton [message #536369 is a reply to message #536221] Thu, 27 May 2010 20:16 Go to previous messageGo to next message
Jeff Johnston is currently offline Jeff JohnstonFriend
Messages: 215
Registered: July 2009
Senior Member
Can you explain what you mean by escape keystroke or provide an example? I have run into the same problem with the menu hanging from the Console button and would like to code a work-around.
Re: Using DropDownButton [message #538083 is a reply to message #536369] Fri, 04 June 2010 21:12 Go to previous messageGo to next message
Jeff Johnston is currently offline Jeff JohnstonFriend
Messages: 215
Registered: July 2009
Senior Member
For those interested, for a drop down toolbar button menu item, you need to add the following call after the button menu item click:

For example, I needed to access the tool bar drop down button for the Console view which allows multiple consoles. The button has a tooltip of "Display Selected Console" and then drops down a radio button menu list of consoles to look at. It numbers them and adds the project name to the items so I used a regex to find the one with the word Configure in it. If I don't add the pressShortcut at the end, it freezes the menu open with my menu item clicked and the previous menu item also clicked, though the console in the tab is the correct one I chose.

view = bot.viewByTitle("Console");
view.setFocus();
SWTBotToolbarDropDownButton b = bot.toolbarDropDownButtonWithTooltip("Display Selected Console");
org.hamcrest.Matcher<MenuItem> withRegex = withRegex(".*Configure.*");
b.menuItem(withRegex).click();
b.pressShortcut(KeyStroke.getInstance("ESC"));

Re: Using DropDownButton [message #787874 is a reply to message #502770] Wed, 01 February 2012 04:18 Go to previous message
Padmanabhan Krishnan is currently offline Padmanabhan KrishnanFriend
Messages: 2
Registered: January 2012
Junior Member
I am facing exactly same problem and seeing the following error:


org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException: Could not find a menu item
at org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownB utton.toSWTBotMenuItems(SWTBotToolbarDropDownButton.java:153 )
at org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownB utton.menuItems(SWTBotToolbarDropDownButton.java:127)
at org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownB utton.menuItem(SWTBotToolbarDropDownButton.java:94)
at org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownB utton.menuItem(SWTBotToolbarDropDownButton.java:81)

I tried adding the code to press shortcut as per Jeff Johnston, but still the problem persists.


Padmanabhan
Previous Topic:SWT tests examples
Next Topic:Problem with Thread Understanding
Goto Forum:
  


Current Time: Fri Apr 19 03:46:32 GMT 2024

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

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

Back to the top