Validation on an object without an ID

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
khartkw
Posts: 2
Joined: Thu Nov 06, 2014 6:32 pm

Validation on an object without an ID

Post by khartkw » Thu Nov 06, 2014 6:48 pm

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.

JToelstede
Posts: 55
Joined: Fri May 24, 2013 12:57 pm

Re: Validation on an object without an ID

Post by JToelstede » Fri Nov 07, 2014 10:49 am

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
Ranorex_Forum.jpg (32.73 KiB) Viewed 749 times
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
Ranorex_Forum_GetValue.jpg (24.66 KiB) Viewed 749 times
Hope that I could help you.

Joe

khartkw
Posts: 2
Joined: Thu Nov 06, 2014 6:32 pm

Re: Validation on an object without an ID

Post by khartkw » Fri Nov 07, 2014 7:10 pm

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!