Thursday, 29 October 2009

Selenium Javascript JQuery UI TreeView

I had an issue today where the tree component of JQuery UI appears to render an additional div element if working in Firefox rather than IE.

This broke my selenium ide test as I could not click on the expandable.

Cut a long story short, here is a snippet of selenium IDE javascript code to get around the problem, but it also demonstrates nicely a function nested within a selenium IDE statement ( I could not find any other sample elsewhere). I hace used bar | symbol to denote split of column values in selenium IDE add-on.

storeElementPresent | //li[@id='1']/div | expandableDivPresent

echo | ${expandableDivPresent}

storeEval | function go() { if (${expandableDivPresent}) { return "//li[@id='1']/div"; } else { return "//li[@id='1']"; } }; go(); | expandableElementXPath

echo | ${expandableElementXPath}
click | ${expandableElementXPath}

No comments: