Geeks With Blogs

News QTP and Stuff

Theo Moore Questions... Morphology? Longevity? Incept dates?
I found something interesting in Selenium today. I use the selenium.getXpathCount a lot in my code. Mostly for dynamically generated tables and such. I also use it in testing as it is best to interrogate the page rather than assume the page structure hasn't changed.

I know,  know...I could isElementPresent() to handle this also, but each execution of isElementPresent() requires selenium to resolve the xpath on each iteration. This is painfully slow. I don't really worry about speed for testing under normal circumstances, but the performance hit in this case is really, really painful. You can use it if you'd like, but I ain't gonna.

But I digress...

I have come code that reads the text out of a set of list item tags using xpath dynamically generated by a loop structure based on the getXpathCount. let's say the first time, getXpathCount returns 13 li tags.  Cool so far. I move to another page then re-count the items (to I can compare the text in the li tags to make sure they've not changed). Essentially it's a new page with the component I am checking refreshed. I visually see that I have 13 li tags in the html. Coolness.

getXpathCount insists there are 26. It has doubled them. Odd.

The same code tests these pages several times (in different languages) and there's no issue.

Going to try some things and see if it continues to be a problem....never seen this particular problem w/Selenium before. Posted on Friday, March 13, 2009 10:49 AM | Back to top

Comments on this post: Selenium: getXpathCount bug?

Comments are closed.
Comments have been closed on this topic.
Copyright © Theo Moore | Powered by: