Tracking dynamic elements on a web page

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
manalitatke
Posts: 36
Joined: Mon Jan 16, 2017 3:24 pm

Tracking dynamic elements on a web page

Post by manalitatke » Thu Aug 31, 2017 3:01 pm

Hello,

In regards to my earlier post: https://www.ranorex.com/forum/object-id ... 11242.html


I understand that image based validation is a fragile method and i should opt for regex parsing.

However, the thing is my web page elements data keeps on dynamically changing everyday.

For eg:
Row 1:
08/31/2017 Data1
The next day this very same data changes to
09/01/2017 Data 2


Now, i need to track these elements using recording modules in order to automate them.


However, even if i use regex properties of >= , it does not give me a robust recording.


Also, i need to make sure that how so ever the dynamic data is changing everyday, i need to get the difference between the changing data and report it.

eg: Data 2 - data 1

i tried using variables, and used the regex pattern in order to track the data elements by setting the inner text to be >= default values in the ranorex path. In this case, the test passes, as the data increments everyday. ( This is the actual data reported everyday being compared with the default value specified in the variables, if the this current data is >= defaultvalue, the test passes)

However, if i try to implement subtraction, it subtracts only the default values and reports them.

But since, the data dynamically changes everyday, how do i implement a logic to subtract the dynamic current data seen on the web page that particular day instead of the default values?


Please let me know of any method or logic.

Thanks!


Also, i tried to convert the web page to its html source and implement the parsing logic. However, it needs some HTML agility pack. Is this feasible with the Ranorex environment?

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Tracking dynamic elements on a web page

Post by krstcs » Thu Aug 31, 2017 3:18 pm

I would suggest that you NOT use the attribute whose value is changing in your XPath. Instead, find another attribute of the element in question, one that doesn't change. You may need to use a combination of attributes or look at parent/child elements.

Typically you want to use the most static attributes for element identification, not ones that change. You can then validate the changing values without worrying about the changes causing issues with identification.
Shortcuts usually aren't...

manalitatke
Posts: 36
Joined: Mon Jan 16, 2017 3:24 pm

Re: Tracking dynamic elements on a web page

Post by manalitatke » Fri Sep 01, 2017 5:50 pm

I can understand.

However, it is the dynamic values which need to be verified every day.

The static values include the name of the data
eg : data 1
data 2 , etc.

For my case, i need to verify how the changing values differ everyday.


Can you elaborate on how i can use the combination of attributes or parent/child elements?


Is there any other alternative?

McTurtle
Posts: 191
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: Tracking dynamic elements on a web page

Post by McTurtle » Tue Sep 05, 2017 1:25 pm

Hello manalitatke,

Would an option be to do the following?
1. Identify the element by an attribute (static value) that does not change at all.
2. Read the values for the dates with "get value" from the same elements, but from different attributes.
3. Do some string splitting, converting to int, calculating the difference and converting back.

Also, it would really help if you could post a snapshot of the elements you need to validate.

Regards,
McTurtle

manalitatke
Posts: 36
Joined: Mon Jan 16, 2017 3:24 pm

Re: Tracking dynamic elements on a web page

Post by manalitatke » Thu Sep 14, 2017 8:05 pm

Hello McTurtle,

Thanks a lot for the response.


Yes, i tried implementing the static value element tracking. However, it does not help much for the changing dynamic date values.

I also tried using 'Get value' attribute. However, again, same, it helps to take an existing repository item, get its specific attribute and assign it to a variable.But this is again tracking existing repository item, and not a dynamic web changing data value for an item.

Yes, finally i implemented the string splitting for inner text attribute, converting it to double and comparing it against default values, doing some arithmetic operations, etc.
It does help as of now.

I was thinking if there was some logic for tracking dynamic elements it would be great, as converting the web page to its frame source element, and then parsing the source code( html using some agility pack) for just getting the values,becomes tedious as a part of automation testing.

Is ranorex compatible with html source code parsing in c# user code?


Please do let me know if there are some other alternatives.

Thanks again!

McTurtle
Posts: 191
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: Tracking dynamic elements on a web page

Post by McTurtle » Fri Sep 15, 2017 12:09 pm

Hello manalitatke,

You would like to track an element via a dynamic attribute (date values)? If no static attribute exists, then I can understand. Do you have a way of knowing what the value of that dynamic attribute will be? If yes, you need to get it via GetValue from another attribute in your AUT, get it from a data source or "generate" it from the current date via code before Ranorex searches for the element in your AUT.

I am afraid that you will have to "foresee" somehow the value of the dynamic attribute or make sure that a static attribute gets implemented.

Regarding your 2nd question. There is no GUI way to do this in Ranorex Studio. However, you could implement it in code. I have found the following link that might help: How can I Convert HTML to Text in C#?

Regards,
McTurtle