Page 1 of 1

How to deal with angularjs span tags

Posted: Wed Sep 14, 2016 10:13 am
by roxter
Hi!
I am busy automating an angularjs web application.
There are some difficulties identifying some of the angular objects.
I would like to perform a click action on a link which resides inside a span tag.

I mapped the object with the spy but when doing playback of the test the object is not found. Ranorex path seems to be incorrect.

Ranorex is not able to find the correct path to the object. Any idea how to deal with angularjs object?
Please see 2nd screenshot.
In the Spy it looks like the object can be correctly mapped, highlighting the element work in the spy.
But when I apply the path to the object in the repository, the object can not be found, please see 1st screenshot.

Re: How to deal with angularjs span tags

Posted: Wed Sep 14, 2016 11:29 am
by odklizec
Hi,

Could you please upload a Ranorex snapshot (not screenshot) and complete xpath as recorded in repository?

The path looks complex, with too many '?', very little unique IDs and some indexes which are often not persistent and likely a cause of your problem. Please post the snapshot, so we can evaluate your xpath.

Re: How to deal with angularjs span tags

Posted: Wed Sep 14, 2016 1:05 pm
by roxter
Hi!
The recorded Xpath is:

/dom[2]//div[#'content']//tag[@tagname='as-selector-view']/div/div[2]/?/?/tag[@tagname='as-structure-tab']/div/div/div[2]/div[1]/a[@href~'^http://localhost:3000/\#/domain']/span[@innertext='Leistungsumfang']

This path to the object will not work if I start the test run, object will not be found.
I attached a snapshot.

Re: How to deal with angularjs span tags

Posted: Wed Sep 14, 2016 1:44 pm
by odklizec
Hi,

As I've suspected, the issue seems to be an index number in the xpath. Is there a reason why you are using /dom[2] at start of the xpath, instead of proper domain name as stored in the snapshot:
/dom[@domain='localhost:3000']
Also, I would suggest further simplify the xpath, to eliminate similar problems in future. Try something like this:
/dom[@domain='localhost:3000']//div[#'content']//tag[@tagname='as-selector-view']/div//tag[@tagname='as-structure-tab']/div//a[@href~'^http://localhost:3000/\#/domain']/span[@innertext='Leistungsumfang']
Hope this helps?