Page 1 of 1

Problem identifying text headings on a website?

Posted: Fri Aug 14, 2015 11:09 am
by Fergal
[Ranorex 5.4, Windows 7, testing a website on Google Chrome 44.0.2...]

I have a series of recorded modules, each for a product page on an eCommerce website. Each individual product page has the brand name as a <h1> heading. When recording, a click on the brand name heading text, gives it the xPath of a generic heading, ending with "/div[1]//h1[@tagname='h1']". Next when the recording is run, without refreshing or making any other change to the product page, Ranorex can't identify the item with the generic heading XPath and the test fails.

When I open Spy and track the brand heading text, it is given its own unique XPath with the brand name as innertext. The XPath ends with "/?/?/h1[@innertext='BrandName']" However, when I drag the element from Spy to the project repository, the Generic Heading repository is highlighted in the repository and no new item is created with the XPath from Spy.

Why is it that when I record a simple click action on a <h1> brand name heading and then immediately run the action step in Ranorex, Ranorex can't find the item on the web page?

Why is it that I can't drag the item from Spy to the repository, to create a new item?

Thanks!

Re: Problem identifying text headings on a website?

Posted: Fri Aug 14, 2015 12:19 pm
by odklizec
Hi Fergal,

It would be helpful if you could post the Ranorex snapshot of each website (or at least few of them).

It seems that the one you recorded does not contain "innertext" because its path is recorded
with tagname attribute?

Code: Select all

"/div[1]//h1[@tagname='h1']"
And I guess the other pages you are testing have different or no tagname and some of them contains innertext, hence Spy prefers to use InnerText instead of TagName?
As mentioned, Ranorex snapshot would be really helpful here.

As for not working Drag&Drop from Spy to repository, I don't have a clue. There must be some kind of test if the path of dragged element is similar/equal to path of an existing repo element and the dropped paths are most probably also optimized? It's better to use //h1 instead of /?/?/h1 (using optional (?) elements in path could make the element search noticeably slower) and therefore the first mentioned path supersedes the other one?

Anyway, you should still be able to add new items manually with Add New Item repository menu.

Re: Problem identifying text headings on a website?

Posted: Mon Aug 24, 2015 4:29 pm
by Fergal
Hi Pavel,

Thank you very much for your help. I'd prefer not to post a snapshot, as this issue was occurring on a client project. It seems it is related to the dom in the xPath. I will do some further research on that and post back here if I have additional questions.

Thanks again!