John,
Am still having some problems with Lists. I think I must be doing
something wrong but I cant figure it out..
Take for example the following html fragment
<div id=main>
...
<div class=myBox>
<div id=heading>Personal Details</div>
<div>
<div>Address</div>
<div>Somewhere 1, Somewhere 1, London, SW13EY</div>
</div>
<div>
<div>Tel</div>
<div>1111111111</div>
</div>
<div>
<div>Email</div>
<div><a href="mailto:test...@somewhere">test...@somwhere</a></
div>
</div>
<div>
<div>Mobile</div>
<div>1111111111</div>
</div>
</div>
</div>
And the model. (NOTE: I am not sure I have used the position attribute
correctly below)
ui.Container(uid: "MainPanel", clocator: [tag: "div", id: "main"]){
List(uid: "UserProfileDetails" ,clocator: [tag: "div" ,
class: "myBox"], separator: "div") {
TextBox(uid:"1" ,clocator: [tag: "div"])
Container(uid: "all" ,clocator: [tag: "div"]) {
TextBox(uid: "Name" ,clocator: [tag: "div",
position: "1"])
TextBox(uid: "Value" ,clocator: [tag: "div",
position: "2"])
}
}
}
Anyway, before the recent change to List.groovy, getListSize
("MainPanel.UserProfileDetails") would have reported "5"
After, the change, it will report "13" as separator "div" will match
all descendant divs. That's ok I though
,as I can remove the separator and use direct: "true" on the List
content objects, like the following:
ui.Container(uid: "MainPanel", clocator: [tag: "div", id: "main"]){
List(uid: "UserProfileDetails" ,clocator: [tag: "div" ,
class: "myBox"]) {
TextBox(uid:"1" ,clocator: [tag: "div" ,
direct: "true"])
Container(uid: "all" ,clocator: [tag: "div" ,
direct: "true"]) {
TextBox(uid: "Name" ,clocator: [tag: "div" ,
direct: "true", position: "1"])
TextBox(uid: "Value" ,clocator: [tag: "div" ,
direct: "true", position: "2"])
}
}
}
I would have expected getListSize("MainPanel.UserProfileDetails") to
return "5" now
But instead the logs show:
01:10:31.563 INFO - Command request: getListSize[jquery=#main
div.myBox, div,div] on session ec03ffac789e4013a4adadc82f38a7eb
01:10:31.586 INFO - Got result: OK,13 on session
ec03ffac789e4013a4adadc82f38a7eb
01:10:31.618 INFO - Command request: getText[jquery=#main div.myBox
div:eq(1) > div > div:eq(0), ] on session
ec03ffac789e4013a4adadc82f38a7eb
01:10:31.655 INFO - Got result: ERROR: Element jquery=#main div.myBox
div:eq(1) > div > div:eq(0) not found on session
ec03ffac789e4013a4adadc82f38a7eb
It looks to me like the direct: "true" attribute is being ignored for
list contents.
Also I am curious about the generated jquery for getText
("MainPanel.UserProfileDetails[2].Name")...it has more div children
that I would have expected..
The correct jquery string should be: #main div.myBox > div:eq(1) >
div:eq(0)
Am I doing something wrong?
Thanks
Rohan
On May 6, 3:05 am, John <[email protected]> wrote:
> Rohanh,
>
> Good question. The direct children came from the old mode that we use
> header + object's xpath + trailer.
> But this mode is really not flexible because it has hard-coded xpath
> there. As a result, it is a bit
> depreciated now. As long as all the List elements on the same sub-tree
> related to its parent, you are fine to
> use not direct children there. As a matter of fact, if you look at the
> generated locator for List without separator,
> they are descendants instead of direct children.
>
> I will apply your change there and commit the code soon.
>
> Thanks,
>
> Jian
>
> On May 5, 6:48 pm, rohanh <[email protected]> wrote:
>
> > I have the following html structure which I wish to represent as a
> > List of repeating groups:
>
> > <div id="main">
> > <span>User blah</span>
>
> > <form method="post">
> > <div id="cols">
> > <div id="col1">
> > <table>
> > <tr>
> > ...
> > content
> > ...
> > </tr>
> > </table>
> > <table>
> > <tr>
> > ...
> > content
> > ...
> > </tr>
> > </table>
> > </div>
> > <div id="col2">
> > <table>
> > <tr>
> > ...
> > content
> > ...
> > </tr>
> > </table>
> > <table>
> > <tr>
> > ...
> > content
> > ...
> > </tr>
> > </table>
> > </div>
> > </div>
> > ...
> > </form>
> > </div>
>
> > The "content" is the same for each table row ( a link and a checkbox,
> > plus some other stuff I dont care about ). I have no control of the
> > html I am testing so at this stage I cannot change it to be more
> > suitable for tellurium. And I dont really care about the layout or
> > positioning of the elements I wish to test, all I want is to able to
> > easily traverse a list and click the links or checkboxes. I though I
> > would be able to do something like the following:
>
> > ui.Container(uid: "MainContent", clocator: [tag: "div", id: "main"],
> > group: "true") {
> > TextBox(uid: "User" , clocator: [tag: "span"])
> > Form(uid: "NetworkSubscriptionForm" , clocator: [method:
> > "post"]) {
> > List(uid: "List" , clocator: [tag: "div", id:
> > "cols"], separator: "tr") {
> > Container(uid: "all" ) {
> > CheckBox(uid: "Subscribe", clocator: [tag:
> > "input, type: "checkbox"] )
> > UrlLink(uid: "Name" , clocator: [href: "^/
> > networks/"])
> > }
> > }
> > SubmitButton(uid: "Submit" , clocator: [name:
> > "send_submit"])
> > }
>
> > }
>
> > However, it seems the Abstract List Containers "separator" is expected
> > to be a direct descendant of the List clocator so this did not work..
> > Is there a technical reason for forcing the separator to be a direct
> > descendant?
>
> > To test a theory, I changed the following code so that the direct
> > descendant restriction was lifted for the separator. It gave the
> > results I was after. This would allow a more flexible referencing of
> > items in tables and repeating patterns with a common ancestor. It
> > should still allow the intended scenarios for lists to work ( I
> > think ) Can you see any problems with this approach?
>
> > Index: core/src/main/groovy/org/tellurium/object/List.groovy
> > ===================================================================
> > --- core/src/main/groovy/org/tellurium/object/List.groovy (revision
> > 1596)
> > +++ core/src/main/groovy/org/tellurium/object/List.groovy (working
> > copy)
> > @@ -129,7 +129,7 @@
> > if (separator == null || separator.trim().size() == 0)
> > return deriveListSelector(index)
>
> > - return " > " + separator + ":eq(${index-1})"
> > + return " " + separator + ":eq(${index-1})"
> > }
>
> > int getListSize(Closure c) {
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"tellurium-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/tellurium-users?hl=en
-~----------~----~----~----~------~----~------~--~---