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);