Letractively / aost

Automatically exported from code.google.com/p/aost
Other
1 stars 0 forks source link

getListSize problem when not use Tellurium Engine #428

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago

<div class="description">
    <p>
        <a target="_blank" href="http://www.yahoo.com"
           rel="nofollow">www.yahoo.com</a><br>
        <a target="_blank" href="http://www.google.com"
           rel="nofollow">www.google.com</a><br>
        <a target="_blank" href="http://www.youtube.com"
           rel="nofollow">www.youtube.com</a>
    </p>
</div>

    ui.List(uid: "description", clocator: [tag: "div", class: "description"]) {
      UrlLink(uid: "{all}", clocator: [:])
    }

    @Test
    public void testGetSListSize(){
        connect("SList");
        useTelluriumEngine(true);
        int size = jlm.getListSize("description");
        System.out.println("List Size " + size);
        useTelluriumEngine(false);
        size = jlm.getListSize("description");
        System.out.println("List Size " + size);
        useTelluriumEngine(true);
    }

Original issue reported on code.google.com by John.Jian.Fang@gmail.com on 19 May 2010 at 2:02

GoogleCodeExporter commented 8 years ago
I looked at the getListSize method in tellurium extension:

Selenium.prototype.getListSize = function(locator, separators) {
    var $e = teJQuery(this.browserbot.findElement(locator));
    if ($e == null || $e.length < 1)
        Assert.fail("Cannot find Element for " + locator);

    var list = $e.children(separators);

    return list.length;
};

The reason you got back zero list size is that the List object with Selenium 
APIs has
to be the immediate
parent of the List elements, which is constrained by the jQuery children 
selector. We
cannot use "find" because
you may have the same tag at different dom levels, which will lead to incorrect 
list
size. But the new Engine does
not have such a limitation because it does group locating.

To solve your problem without new Engine, you can define the ui module as 
follows

    ui.Container(uid: "description", clocator: [tag: "div", class: "description"]) {
      List(uid: "p", clocator: [tag: "p"]){
        UrlLink(uid: "{all}", clocator: [:])
      }
    }

Then, the following command should get back the list size correctly

getListSize("description.p");

Original comment by John.Jian.Fang@gmail.com on 19 May 2010 at 7:52