LabelTextLocator does not work

WindowTester allows you to easily create and run unit tests for every GUI they build. It can also be used to generate system level tests.

Moderators: gnebling, Eric Clayberg, Dan Rubel, keertip, Phil Quitslund

LabelTextLocator does not work

Postby arpitdesai » Thu Apr 16, 2009 1:17 pm

Hello,

I am trying to find a Text widget next to a label on a UIFrom as seen below

ui.click(new LabeledTextLocator("Headline:"));
ui.enterText("TestingBSI");

Here is my widget stack. As you can see "Headline:" label is visible and listed. I want to get the Text {}<HC|26869889> using the code above but always get Widget Not Found exception. I even tried to give the Section as the parent to the above call but same result.

Label {Headline:}<HC|4818632>
MultiValueText {}<HC|19917564>
Text {}<HC|26869889>
Label {Summary:}<HC|15484671>
MultiValueText {}<HC|2705732>
Text {}<HC|26691382>
Label {Project:}<HC|8987637>
MultiValueTextWithSelectionList {}<HC|26722737>
Text {}<HC|12865003>
Button {...}<HC|30910387>

Any suggestions how I can get it working ?
Note: in above widget hierarchy Label->MultiValueText(my composite)->Text{}. From what I understand the search is depth first and so it should find it. Am I wrong ?

Thanks,
- Arpit
Attachments
form.png
form.png (5.18 KiB) Viewed 443 times
arpitdesai
 
Posts: 6
Joined: Thu Apr 16, 2009 6:56 am

Re: LabelTextLocator does not work

Postby Phil Quitslund » Thu Apr 16, 2009 9:08 pm

Here are the docs for LabeledLocators:

Locates a widget that is immediately adjacent to (e.g., following) a Label widget with the given label text.

For instance, this locator:

new LabeledLocator(Text.class, "File:");

identifies a Text widget that is preceded by the "File:" label.

(A widget w1 is considered to be preceding another widget w2 if they are siblings with the same Composite parent c1 and the index of w1 is just before the index of w2 in c1's list of children.)


I think the labeled locator would match the MultiValueText in your example.

Given that, you might try this instead:

Code: Select all
ui.click(new LabeledLocator(MultiValueText.class, "Headline:"));


Let us know how it goes!
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Re: LabelTextLocator does not work

Postby arpitdesai » Fri Apr 17, 2009 7:15 am

Phil,

Thanks for the reply, I had certainly missed the definition of 'adjacent element'. I understand how it would work now.
However, I am not able to figure out what LabelLocator only restricts itself to that particular composite and does not dive into adjacent composites ? (depth first search)

As you can see there are clear advantages if WindowTester API does that for me vs me having to locate the composite and then locate something within it. This adds to the test generation logic and also would be vulnerable to implementation change.

My test would break if someone decides to call MultiValueText something else.

Could you explain what is the reason for restricting the search to immediate parent composite ?

Thank you,
- Arpit
arpitdesai
 
Posts: 6
Joined: Thu Apr 16, 2009 6:56 am

Re: LabelTextLocator does not work

Postby Phil Quitslund » Mon Apr 20, 2009 10:20 am

Hi Arpit,

All good points.

Could you explain what is the reason for restricting the search to immediate parent composite ?


Really just simplicity. The less moving parts the better. The easier to explain a heuristic for matching, the better.

Now, all that said, perhaps we should revisit. More likely, we should cook up a new locator to satisfy your needs. If you can provide us with some tests to drive implementation we'll be happy to put something together for you. Alternatively, if you want to roll this for yourself, we'll be happy to help with pointers as well.

Thanks!

-phil
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am


Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest