1. #1
    Ext GWT Premium Member
    Join Date
    Mar 2009
    Posts
    226
    Vote Rating
    3
    The_Jackal is on a distinguished road

      0  

    Default Selenium Click on TreeItem

    Selenium Click on TreeItem


    TreeItem clicks only work sometimes. In my IDE (running from JUnit) they almost always register the click, but from Ant they almost never register the click.

    I think that its something to do with when the javascript is attached to the div and ant is running the tests too quickly.

    Currently I wait for the tree to appear and be open with:

    Code:
    //div[@id="myTreePanelId" and @class="my-tree x-unselectable"]//div[@id="myTreeItemCategotyId" and @class="my-treeitem"]//div[@class="tree-folder-open"]
    Where myTreePanelId and myTreeItemCategotyId are id's I've set manually.

    Then I wait for the item to appear and have "display: block" (rather than "none"):

    Code:
    //div[@id="myTreePanelId" and @class="my-tree x-unselectable"]//div[@id="myTreeItemCategotyId" and @class="my-treeitem"]//div[@class="my-tree-ct" and contains(@style, "display: block;")]/div[@id="myTreeItemId" and @class="my-treeitem"]
    Where myTreeItemId is a manually set id on the tree item I want to click.

    Anyone know how to reliably click on a tree item?

    I use this method to wait for xpath locators:

    Code:
        public static void waitForElementPresent(final Selenium selenium, final String locator, int timeout)
        {
            new Wait() {
                public boolean until() {
                    return selenium.isElementPresent(locator);
                }
            }.wait("Error: Element with locator '" + locator + "' not found", timeout);
        }
    And focus and click to click on the tree item:

    Code:
            selenium.focus(locator);
            selenium.click(locator);

  2. #2
    Ext GWT Premium Member
    Join Date
    Mar 2009
    Posts
    226
    Vote Rating
    3
    The_Jackal is on a distinguished road

      0  

    Default FIXED

    FIXED


    I think that GXT adds events after the html is created, therefore isElementPresent returns true, but clicks are not recognised.

    The solution (for me) was to wait till the tree panel has the onclick set:

    Code:
        public static void waitForElementOnClickAvailable(Selenium selenium, String id, int timeout)
        {
            selenium.waitForCondition( "selenium.browserbot.getCurrentWindow().document.getElementById('" + id + "').onclick != null", Integer.toString(timeout));
        }
    This also makes clicking on tree items much more reliable (I was getting failures if the test ran too fast).

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..."