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.
Validation on an object without an ID
-
- Posts: 55
- Joined: Fri May 24, 2013 12:57 pm
Re: Validation on an object without an ID
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: 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
(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.
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. Hope that I could help you.
Joe
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: 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']
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)$']
Now you can work with the dynamic tag like shown in the following pic. Hope that I could help you.
Joe
You do not have the required permissions to view the files attached to this post.
Re: Validation on an object without an ID
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!
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!