tags:

views:

163

answers:

1

Hi all,

In Selenium RC I need to expand/click a node in a tree made with RichFaces. I have done a TreeUtil class, but at this point I am not sure how to click/expand a node (which I retrieve with this xpath: "//div[@id='foo:classTree']/div/div/table["+nodeLevel+"]/tbody/tr/td/div/a") using only a nodeNumber and a nodeLevel.

Anybody has any idea?

+1  A: 

Your question isn't very clear to me: are those click commands (with the XPath) not working because they result in "element not found" errors or because the click simply isn't causing the behavior your expect?

If it's an element-not-found issue, I suggest you use Firebug's $x function in the console to refine your XPath. You can run this function call in the Firebug function to see what the XPath is truly evaluating to:

$x("//div[@id=\"foo:classTree\"]/div/div/table[XXX]/tbody/tr/td/a")

Where XXX is some index. This is by far the best way to figure out the right XPath.

If the problem is that the click is just not really causing the tree map to change, try switching from click() to fireEvent("//xpath", "click") and see if that helps.

Patrick Lightbody
My question wasn't very clear to me because the problem wasn't very clear to me at that time. Now I realized that the same xpath can produce different results and this depends entirely on the way the tree is expanded at the time.Another thing is that you cannot test to see if a node which was expanded and then again collapsed is visible because it is still detectable with the same xpath.
ratzusca