Page 1 of 1

Validation on an object without an ID

Posted: Thu Nov 06, 2014 6:48 pm
by khartkw
I am evaluating Ranorex 5.2 on windows 7 32bit and testing an web app on IE 11.

The application has a sidebar menu and inside one of those menu items is a badge-danger element with a number inside of it. This number shows the number of submitted articles available for review. I want to validate that the number increases by one when I submit an article. The problem is, the badge element does not have a name, so it is being identified by the innertext. Once I run the test, there is a different number there, so it does not recognize it and my test stops. Any help would be greatly appreciated.

Re: Validation on an object without an ID

Posted: Fri Nov 07, 2014 10:49 am
by JToelstede
Hi khartkw,

do you have a static lable or any other static element with a name near to the badge element?
If so you could try to use this element for identification of the badge element.

Here an excample by using the ranorex forum site:
Ranorex_Forum.jpg
The following RxPath would identify the dynamic 'p'-tag element exactly at the date 11/07/2014 at 9:36 am but not on the date 11/07/2014 at 9:40 am

Code: Select all

/dom[@caption~'^Ranorex\ Forum\ -\ Software\ ']//div[#'page-body']/p[@innertext='It is currently Fri Nov 07, 2014 9:36 am']
(Please notice that ranorex would not suggest you the RxPath above. I have edit the path for this excample).
To identify the dynamic 'p'-tag I would use an other element with a static text, go back in the rxpath to the last common parent-elemnt by using '/../' and add the path to the dynamic 'p'-tag.

Code: Select all

/dom[@caption~'^Ranorex\ Forum\ -\ Software\ ']//div[#'page-body']//a[@innertext='View active topics']/../../../p[@innertext~'[0-9]{2}:[0-9]{2} (am|pm)$']
In your case you could use a regex like p[@innertext~'[0-9]'].
Now you can work with the dynamic tag like shown in the following pic.
Ranorex_Forum_GetValue.jpg
Hope that I could help you.

Joe

Re: Validation on an object without an ID

Posted: Fri Nov 07, 2014 7:10 pm
by khartkw
Joe,

Thank you for the help. I did get it to work before I saw your reply, but was wondering how to make it more reliable and repeatable than what I did. I think this will be the right direction for me to go. Thanks again!