Would like to have relative searching based on Composite parent [message #525796] |
Wed, 07 April 2010 15:56  |
Eclipse User |
|
|
|
In creating my SWTBot tests, I find that a number of widgets do not have labels so I am forced to use an index. This makes my tests very fragile.
In many cases, there is in fact a label close by. For example, a StringFieldEditor takes a label argument, but actually creates a Label beside a Text widget. If one could say: "find me the Text widget that is after label "X" or find me the Nth Text widget for the Composite which is the direct parent of label "Y", this would make the tests better able to withstand UI changes elsewhere on a Window which may be out of my control (e.g. the Properties dialog).
Seem reasonable?
|
|
|
|
|
Re: Would like to have relative searching based on Composite parent [message #525826 is a reply to message #525796] |
Wed, 07 April 2010 17:12   |
Eclipse User |
|
|
|
There are quite a few things that swtbot provides:
<widget>WithLabel:
bot.textWithLabel('your label')
This one looks for the *first* textbox after a label, not necessarily
the one immediately next to it, possibly even from a different
composite. It basically does a depth first traversal of the UI, adds
each widget into a list as it traverses. It then matches a label and
finds any text box after after the label.
<widget>InGroup:
bot.textWithLabelInGroup(label, group)
This one does something similar, but does a depth first traversal of the
group and not the entire shell, so I'd recommend using inGroup for
improving readability and reduce the number of places where you use indexes.
If you could provide a screenshot of the app and the control you can
access, we could help better.
– Ketan
eclipse.org/swtbot | twitter.com/ketanpkr
On 4/7/10 12:56 PM, Jeff Johnston wrote:
> In creating my SWTBot tests, I find that a number of widgets do not have
> labels so I am forced to use an index. This makes my tests very fragile.
>
> In many cases, there is in fact a label close by. For example, a
> StringFieldEditor takes a label argument, but actually creates a Label
> beside a Text widget. If one could say: "find me the Text widget that is
> after label "X" or find me the Nth Text widget for the Composite which
> is the direct parent of label "Y", this would make the tests better able
> to withstand UI changes elsewhere on a Window which may be out of my
> control (e.g. the Properties dialog).
>
> Seem reasonable?
|
|
|
|
|
|
|
|
Re: Would like to have relative searching based on Composite parent [message #526137 is a reply to message #526133] |
Thu, 08 April 2010 16:27  |
Eclipse User |
|
|
|
Thanks again. That was it. The message has an additional space at the end. It would be nice if the function could do a trim() of strings before comparing the label text so as to make this thing a little harder to stumble upon. It is nicer to read the actual string text in the test rather than have to go look up the actual magic string. As well, the string class may not be exposed.
|
|
|
Powered by
FUDForum. Page generated in 0.04436 seconds