Page 1 of 1

Blocker:testing my AngularJS App having no static element

Posted: Tue May 10, 2016 7:28 am
by zeeshan sabir
Hi Zeeshan Here!

I'm testing my DataGridApp through Ranorex studio.But as my app is designed in angularjs so i'm blocked while executing my test cases.When i execute my test cases after recording in an efficient way,many of the elements becomes unable to find as they have no such static attribute through which they can be detected each time.Kindly guide me about its solution.Its a huge blocker for me since a number of weeks.

Thanks in advance :)

Re: Blocker:testing my AngularJS App having no static element

Posted: Tue May 10, 2016 8:29 am
by odklizec
Hi Zeeshan and welcome here,

If I understand you right, the problem you are facing is caused by dynamic IDs, which are changing with each application start, right?

Could you please post a Ranorex snapshot (not screenshot!) of the problematic element(s) and an example xpath recorded by Ranorex, which fails during the test playback? Also, please post exact error message you are getting.

Additionally, I would suggest you to check this blog post about testing apps with dynamic IDs...
http://www.ranorex.com/blog/automated-t ... namic-ids/

Re: Blocker:testing my AngularJS App having no static element

Posted: Wed May 11, 2016 7:23 am
by zeeshan sabir
Its not about dynamic id issue.As element is being identified on the basis of text content that remains consistent.But on multiple time executing same test case,that element becomes unable to be identified and test case fails.The reason as far that i have understood that xpath being generated against that elements changes each time unconsistently.Due to which that element (buttons etc) is not being identified further.I'm attaching the snapshot against one of the scenerio.But i have many such blockers.

Re: Blocker:testing my AngularJS App having no static element

Posted: Wed May 11, 2016 8:17 am
by odklizec
OK, now please post also an example xpath related to the snapshot you uploaded (as it was recorded by Ranorex), and which typically fails.

It definitely sounds like a dynamic ID issue. Apparently, your GUI lacks unique IDs so you will either have to simplify recorded xpaths or use relative arguments to other elements. In any case, you will most probably have to edit each recorded xpath to make it more robust. You see, recording is a nice help, but not something you should 100% rely on. After each recording session (which should be as short as possible), you should always review and (if needed) modify the xpath.

Re: Blocker:testing my AngularJS App having no static element

Posted: Wed May 11, 2016 8:25 am
by zeeshan sabir
/dom[@domain='localhost:8001']//tag[#'tab-content-0']/div/div/div/div[1]/div[1]/div[2]/div[4]/?/?/button[@innertext~'^\ Test\ Query\ \ \ \ \ \ \ \ \ \ \ \ \ ']

This is one of the xpath of a "tset query" button...

And can you please guide me that how to resolve this issue.I was thinking that it should be resolved by developers by assigning a unique id to each element.Isn't it???

But then on other side,Its an angular js app in which dynamic ids are being generated automatically.So what can be the most appropriate soluyion while testing an angular js app in which you don't have elements having any static attribute???

Please help me in this severe issue i have stuck in.

Thanks in advance :)

Re: Blocker:testing my AngularJS App having no static element

Posted: Wed May 11, 2016 9:02 am
by odklizec
Unfortunately, the dynamically created IDs (by app) are often useless, because part of their string is usually random ;)

For example, ID like this is very fragile:
//tag[#'tab-content-0']
The number part of the ID string may very well change in future? So it may be better to use something like this instead:
//tag[@id~'tab-content']
The problem is, that this kind of ID could return multiple tag elements using "tab-content" ID string. So you need to specify also other parts of xpath (after this attribute) to help Ranorex to find a correct element.

Unfortunately, there seems to be no button "Test Query" anywhere in the snapshot you uploaded. So you either published wrong snapshot or the button has been renamed in a meantime and therefore, it can't be find by Ranorex ;)

The closest thing I found is 'Query' button, which can be found at two places:
/dom[@domain='localhost:8001']//div[#'page-wrapper']//tag[@tagname='md-content']//tag[@tagname='md-tabs-wrapper']/tag[@tagname='md-tabs-canvas']/tag[@tagname='md-pagination-wrapper']/tag/span[@innertext=' Query']
and...
/dom[@domain='localhost:8001']//div[#'page-wrapper']//tag[@tagname='md-content']//tag[@tagname='md-tabs-wrapper']/tag[@tagname='md-tabs-canvas']/div[@class='md-visually-hidden md-dummy-wrapper']/tag/span[@innertext=' Query']
BTW, I think it would be best for you to edit the xpath weight (as described in the blog post I mentioned) and give "tagname" and "class" attributes a priority over other attributes? This could help you with generating better xpaths during recording? But even then, i would suggest to review and simplify the xpaths after each recording action.

As for the xpath you publixhed, I would suggest to simplify it like this:
/dom[@domain='localhost:8001']//tag[@id~'tab-content-']//button[@innertext~'Test\ Query']
You see, there is really no pint of referring to all these empty spaces in "Test Query" button and also all these divs with indexes are often useless, because they will soon or later fail due to changes in GUI. You should use indexes only if there is absolutely no other way and even then you should use them with a great caution!

Re: Blocker:testing my AngularJS App having no static element

Posted: Wed May 11, 2016 11:00 am
by zeeshan sabir
yeah i had sent you the snapshot of delete button.
Now im sending you the snapshot of test query button.
And now i try to change the weights and then record the test case again then will tell you.

Re: Blocker:testing my AngularJS App having no static element

Posted: Wed May 11, 2016 11:24 am
by zeeshan sabir
I'm trying to change weight of elements by going GlobalSettings->Advanced->Edit Path Weights

and then im attaching screenshot of the window that is opened...Kindly guide me that what to do further to set the weight.

Re: Blocker:testing my AngularJS App having no static element

Posted: Wed May 11, 2016 11:35 am
by odklizec
Please follow the tutorial in the mentioned blog post...
http://www.ranorex.com/blog/automated-t ... /#add-rule

At first, reduce the weight rule of (webelement) "ID" attribute to 0, then increase the weight number of "class" attribute to 200. Eventually, keep the ID number as as (default 200) and increase the weight number of "class" to 201 or higher.

The same you can do with every available attribute. Basically, you need to increase the weight number of any attribute you want to give a priority over the one with higher weight number. Hope this helps?

Re: Blocker:testing my AngularJS App having no static element

Posted: Wed May 11, 2016 12:12 pm
by zeeshan sabir
I followed each step of the tutorial.But the weight that i set is not being saved and previous weights are being appeared in the overview explorer even after i applied the new weight.Why is this happening???
And can you guide me over skype or by accessing my machine remotely?
The issue that im facing right now is that weights against each attribute is not being set.

Re: Blocker:testing my AngularJS App having no static element

Posted: Thu May 12, 2016 11:05 am
by zeeshan sabir
hi,
I was expecting your reply.Kindly tell me whether you can help me out in my issue or not.Actually,we have to purchase an automation tool after confirming that it fulfills our all requirements or not.Ranorex was looking better and user friendly than other tools that i have explored.So thats why,i'm spending more time over it.But need some assistance of you on behalf of this tools.
I have tried to modify xpath manually according to my understanding.But still unable to resolve problem.Some of my buttons are not being able to be found while some others are not being clicked at the right position.There appears click on smwhere else in the screen instead of the required button and test case appears pass.
Waiting for your response.

Regards,
Zeeshan Sabir
Associate Software Quality Assurance Engineer
Sensys pvt ltd

Re: Blocker:testing my AngularJS App having no static element

Posted: Thu May 12, 2016 12:26 pm
by odklizec
Hi,

I'm sorry, I can't help you remotely. I think the xpath weight editor and its workflow is nicely described in the mentioned blog post and it works fine for me. If it does not work for you, then you should contact Ranorex support (at [email protected]) and I'm sure they will gladly do a remote session with you. You see, I'm just a Ranorex user and I cannot spend much more time supporting people ;)

Generally speaking, Ranorex does a very nice job identifying controls and most of the time, you should not be in a need to mess-up with xpath weight editor. I'm working with Ranorex for about 3 years, and I edited xpath weight maybe less than handful times.

Unfortunately, your app looks pretty automation unfriendly, with very few unique (and persistent) IDs. Hence it would require some clever work with xpaths and manual editing of each recorded xpath.

If Ranorex clicks at other places than expected, then it's most probably caused by incorrect xpath, pointing to a wrong element (make sure Ranorex spy does not detect multiple elements for given xpath!).

Eventually, the page/element you are working on is not completely ready at a time of click? This is a mmost comon problem of web pages. In these cases, it may be required to use WaitForExists, EnsureVisible or small delay before each problematic element, which often fails. There may be also other reasons for such misclicks, but it's pretty hard to suggest something reliable without seeing your app, exact error message you are getting, failing xpaths and element snapshots created for failing elements. If you search this forum, you may find many discussions and equivalent number of suggestions regarding misclicks.

Re: Blocker:testing my AngularJS App having no static element

Posted: Thu May 12, 2016 12:41 pm
by zeeshan sabir
Ohkay...thanks alot for your time...I thought that you must be a renorax employee to guide people...Thats why was taking your as much time...But thanks alot for your as much assistance.Now i think i should contact them via mail...stay blessed :)