Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Finding n-th widget of any type
Finding n-th widget of any type [message #15433] Mon, 19 January 2009 15:36 Go to next message
Hans Schwaebli is currently offline Hans SchwaebliFriend
Messages: 70
Registered: July 2009
Member
Is it possible or does it make sense to add this feature to SWTBot?

Description: Finding the n-th widget of a certain type.

The reason for this idea: It could be nice for finding widgets which
aren't yet supported by SWTBot. So there would perhaps be no showstoppers
of that kind.

For example: SWTBot#widget(String type, int index) returns
org.eclipse.swt.widgets.Widget.

Or an API with generics if it is possible to return the object without
having to cast it.

What do you think about this?
Re: Finding n-th widget of any type [message #15497 is a reply to message #15433] Tue, 20 January 2009 02:35 Go to previous messageGo to next message
Ketan Patel is currently offline Ketan PatelFriend
Messages: 68
Registered: July 2009
Member
There are already APIs for things like that which take matcher as input.
Here is an example of one (see SWTBotFactory for more):
public Widget widget(Matcher<?> matcher, int index)

Using a matcher is nice because you can easily reuse existing matchers,
group them and make some nice combinations.

Matcher matcher = allOf(widgetOfType(Button.class), withTooltip(tooltip),
inGroup(inGroup), withStyle(SWT.PUSH, "SWT.PUSH")); //$NON-NLS-1$
Re: Finding n-th widget of any type [message #15654 is a reply to message #15497] Tue, 20 January 2009 08:55 Go to previous messageGo to next message
Hans Schwaebli is currently offline Hans SchwaebliFriend
Messages: 70
Registered: July 2009
Member
Thank you. I haven't discovered that method. I looked in the class SWTBot
for a method named "widget", but haven't found it. I forgot to look into
its super class.
Re: Finding n-th widget of any type [message #16396 is a reply to message #15497] Tue, 20 January 2009 13:13 Go to previous messageGo to next message
Hans Schwaebli is currently offline Hans SchwaebliFriend
Messages: 70
Registered: July 2009
Member
Its not quite the solution.

Custom widgets don't need to extend the SWT Widget class necessarily. In
this case the methods "widgetOfType" don't work.

I am currently trying to write a method which can find objects of any type
within the GUI.
Re: Finding n-th widget of any type [message #16411 is a reply to message #16396] Wed, 21 January 2009 00:32 Go to previous messageGo to next message
Ketan Patel is currently offline Ketan PatelFriend
Messages: 68
Registered: July 2009
Member
I guess so, but I just have never seen SWT custom widget which does not
extend widget...I guess the existing methods would work with generic...

Can you provide an example where swt widget does not extend the Widget
class?


Hans Schwaebli wrote:

> Its not quite the solution.

> Custom widgets don't need to extend the SWT Widget class necessarily. In
> this case the methods "widgetOfType" don't work.

> I am currently trying to write a method which can find objects of any type
> within the GUI.
Re: Finding n-th widget of any type [message #16425 is a reply to message #16411] Wed, 21 January 2009 10:10 Go to previous messageGo to next message
Hans Schwaebli is currently offline Hans SchwaebliFriend
Messages: 70
Registered: July 2009
Member
Ketan Patel wrote:
> Can you provide an example where swt widget does not extend the Widget
> class?

Nebula widgets, for example FormattedText. Instances are created by
passing a Text object when creating a new Nebula widget. They are loosely
coupled with listeners and not by extension or aggregation.
Re: Finding n-th widget of any type [message #16513 is a reply to message #16425] Thu, 22 January 2009 01:06 Go to previous messageGo to next message
Ketan Patel is currently offline Ketan PatelFriend
Messages: 68
Registered: July 2009
Member
I don't see how you can find FormatterText. You will only be able to find
the Text since that is the only thing known by the Composite holding it.
Unless you have ways to hook into the JVM itself to inspect the objects.

Hans Schwaebli wrote:

> Ketan Patel wrote:
>> Can you provide an example where swt widget does not extend the Widget
>> class?

> Nebula widgets, for example FormattedText. Instances are created by
> passing a Text object when creating a new Nebula widget. They are loosely
> coupled with listeners and not by extension or aggregation.
Re: Finding n-th widget of any type [message #16547 is a reply to message #16513] Thu, 22 January 2009 08:34 Go to previous messageGo to next message
Hans Schwaebli is currently offline Hans SchwaebliFriend
Messages: 70
Registered: July 2009
Member
I cannot find the text field (which is "decorated" by Nebula using
listeners) by label. So I was looking for an alternative way, which is
described in this thread. I will try to find it by ID, maybe that will
work, at least as an workaround. Maybe it was not the best decision of the
Nebula design team not to use inheritance, since their classes are
widgets, so they should extend the Widget class I think.


Ketan Patel wrote:

> I don't see how you can find FormatterText. You will only be able to find
> the Text since that is the only thing known by the Composite holding it.
> Unless you have ways to hook into the JVM itself to inspect the objects.

> Hans Schwaebli wrote:

>> Ketan Patel wrote:
>>> Can you provide an example where swt widget does not extend the Widget
>>> class?

>> Nebula widgets, for example FormattedText. Instances are created by
>> passing a Text object when creating a new Nebula widget. They are loosely
>> coupled with listeners and not by extension or aggregation.
Testability of nebula widgets (Re: Finding n-th widget of any type) [message #16564 is a reply to message #16547] Thu, 22 January 2009 09:33 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
Nebula users,

(CC'ing the nebula newsgroup for more inputs on this)

There have been numerous requests from SWTBot users for adding support
for testing Nebula widgets. This happens to be one such case.

One of the things that prevents testability is when nebula exposes its
internals by way of exposing individual SWT controls and not 'nebula
controls'.

An example would be the date/time controls. Users would ideally want to
interact with some form of a DateTimeComposite as a single widget that
performs all operations pertaining to date and time and not as a set of
individual widgets that they need to orchestrate.

Can the nebula team help in this regard ? Can I help in any way in this?

-- Ketan

On 22/1/09 14:04, Hans Schwaebli wrote:
> I cannot find the text field (which is "decorated" by Nebula using
> listeners) by label. So I was looking for an alternative way, which is
> described in this thread. I will try to find it by ID, maybe that will
> work, at least as an workaround. Maybe it was not the best decision of
> the Nebula design team not to use inheritance, since their classes are
> widgets, so they should extend the Widget class I think.
>
>
> Ketan Patel wrote:
>
>> I don't see how you can find FormatterText. You will only be able to
>> find the Text since that is the only thing known by the Composite
>> holding it. Unless you have ways to hook into the JVM itself to
>> inspect the objects.
>
>> Hans Schwaebli wrote:
>
>>> Ketan Patel wrote:
>>>> Can you provide an example where swt widget does not extend the
>>>> Widget class?
>
>>> Nebula widgets, for example FormattedText. Instances are created by
>>> passing a Text object when creating a new Nebula widget. They are
>>> loosely coupled with listeners and not by extension or aggregation.
>
>
Re: Testability of nebula widgets (Re: Finding n-th widget of any type) [message #17561 is a reply to message #16564] Fri, 23 January 2009 04:07 Go to previous messageGo to next message
Jeremy Dowdall is currently offline Jeremy DowdallFriend
Messages: 181
Registered: July 2009
Senior Member
Hi Ketan,

Thanks for cc'ing us on this.

Working with SWTBot would be great for some of the things I'm working
on, and getting all Nebula widgets to well with it is a goal we should
always be thinking about, but I think I first need to brush up on it
before I have any intelligent questions or suggestions on how to get
started. I'll see what I can dig into over the next week, and then I'd
like to follow up on how to get CDateTime, and especially its core,
working with SWTBot.

cheers,
Jeremy

Ketan Padegaonkar wrote:
> Nebula users,
>
> (CC'ing the nebula newsgroup for more inputs on this)
>
> There have been numerous requests from SWTBot users for adding support
> for testing Nebula widgets. This happens to be one such case.
>
> One of the things that prevents testability is when nebula exposes its
> internals by way of exposing individual SWT controls and not 'nebula
> controls'.
>
> An example would be the date/time controls. Users would ideally want to
> interact with some form of a DateTimeComposite as a single widget that
> performs all operations pertaining to date and time and not as a set of
> individual widgets that they need to orchestrate.
>
> Can the nebula team help in this regard ? Can I help in any way in this?
>
> -- Ketan
>
> On 22/1/09 14:04, Hans Schwaebli wrote:
>> I cannot find the text field (which is "decorated" by Nebula using
>> listeners) by label. So I was looking for an alternative way, which is
>> described in this thread. I will try to find it by ID, maybe that will
>> work, at least as an workaround. Maybe it was not the best decision of
>> the Nebula design team not to use inheritance, since their classes are
>> widgets, so they should extend the Widget class I think.
>>
>>
>> Ketan Patel wrote:
>>
>>> I don't see how you can find FormatterText. You will only be able to
>>> find the Text since that is the only thing known by the Composite
>>> holding it. Unless you have ways to hook into the JVM itself to
>>> inspect the objects.
>>
>>> Hans Schwaebli wrote:
>>
>>>> Ketan Patel wrote:
>>>>> Can you provide an example where swt widget does not extend the
>>>>> Widget class?
>>
>>>> Nebula widgets, for example FormattedText. Instances are created by
>>>> passing a Text object when creating a new Nebula widget. They are
>>>> loosely coupled with listeners and not by extension or aggregation.
>>
>>
>
Re: Testability of nebula widgets (Re: Finding n-th widget of any type) [message #17574 is a reply to message #17561] Fri, 23 January 2009 04:24 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
Hi Jeremy,

The reference to DateTime was purely as an example, and I'm not sure if
the widget is actually testable (or not) with SWTBot.

I'm happy to answer any questions that may help improve testability of
the widgets, as it'll help nebula users write better tests.

-- Ketan

On 23/1/09 09:37, Jeremy Dowdall wrote:
> Working with SWTBot would be great for some of the things I'm working
> on, and getting all Nebula widgets to well with it is a goal we should
> always be thinking about, but I think I first need to brush up on it
> before I have any intelligent questions or suggestions on how to get
> started. I'll see what I can dig into over the next week, and then I'd
> like to follow up on how to get CDateTime, and especially its core,
> working with SWTBot.
Re: Testability of nebula widgets (Re: Finding n-th widget of any type) [message #17613 is a reply to message #17574] Fri, 23 January 2009 13:08 Go to previous message
Jeremy Dowdall is currently offline Jeremy DowdallFriend
Messages: 181
Registered: July 2009
Senior Member
CDateTime is the widget I primarily work on, so it's the best for me to
start with. Once I understand SWTBot better I can certainly help with
the other widgets, but Nebula is presently comprised of independent lone
developers working on their own widget(s).
I also mentioned CDateTime's core because that is being broken out into
a more universal toolkit for making other custom widgets. Working with
you on this piece is of the greatest interest to me because then other
widgets that are based on it will benefit (not just CDateTime).
From the outside, CDateTime is probably testable with SWTBot as-is, but
internally - definitely not. This is also a part I want to explore as
we need automated testing of the actual widget as much as app developers
need testing of their whole UI.

Ketan Padegaonkar wrote:
> Hi Jeremy,
>
> The reference to DateTime was purely as an example, and I'm not sure if
> the widget is actually testable (or not) with SWTBot.
>
> I'm happy to answer any questions that may help improve testability of
> the widgets, as it'll help nebula users write better tests.
>
> -- Ketan
>
> On 23/1/09 09:37, Jeremy Dowdall wrote:
>> Working with SWTBot would be great for some of the things I'm working
>> on, and getting all Nebula widgets to well with it is a goal we should
>> always be thinking about, but I think I first need to brush up on it
>> before I have any intelligent questions or suggestions on how to get
>> started. I'll see what I can dig into over the next week, and then I'd
>> like to follow up on how to get CDateTime, and especially its core,
>> working with SWTBot.
>
Previous Topic:Selecting context menu and sub-menu items
Next Topic:CONSECUTIVES TEST
Goto Forum:
  


Current Time: Wed Apr 24 19:44:25 GMT 2024

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

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

Back to the top