|Re: Can't access main "Project" menu after selecting project in view [message #525712 is a reply to message #525559]
||Wed, 07 April 2010 14:23
| Pascal G
Registered: July 2009
Jeff Johnston wrote:|
> Pascal G wrote on Tue, 06 April 2010 12:24
>> Jeff Johnston wrote:
>> > Thanks for the tip Pascal.
>> > I tried changing the test to just get the menu for "Project" from
>> bot > and then try a menu.click(). When I run this (as opposed to
>> debug), I > get a dialog that pops up that says: "The chosen operation
>> is not enabled".
>> something like: bot.menu("Project").click(); ??? I think that's what
>> is causing your pop-up dialog, but I'm not sure. Menu management in
>> SWTBot is a bit messy, there were various bug report surrounding this
>> if I remember well. Or it was context menus? Anyways, from my
>> experience, you should only do action on leaf menu, such as the
>> Properties item, and not the Project one.
>> Base line: you should really do
> I tried this first. It gives me the WidgetNotFound exception yet
> again. :(
> I guess I should open a bug.
Hmmmmm.... ding! Found it! I tried finding this menu myself and here is
what I get: it finds the wrong "Project" menu item. It finds the one
that is located in Search -> Text . Clearly not the behavior I would
expect: it does a recursive search using a depth-first approach. I would
of done this without recursion, or if recursion is absolutely necessary
I would prefer a breadth-first approach... To get the one you're
after, do this instead:
bot.menu("Project", 1); // Get the second Project menu item...
On a side-note, you could also do bot.menu("Properties", 1) instead of
the chaining. Note that again I had to specify index 1, because the
first "Properties" MenuItem is located under the File menu.
I'm going to open a bug on this issue, probably to add a new API to
specify if the search should be recursive or not:
bot.menu("Text", index, recursive);
I would like it to not be recursive by default, but that would probably
break a lot of people's test since they may rely on this behavior...
We could also discuss to fact to use depth-first vs breadth-first.
Hope this helps.
Pascal Gélinas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/
*Because performance matters.*
Powered by FUDForum
. Page generated in 0.01710 seconds