Element colour attribute tracking

Class library usage, coding and language questions.
nirs
Posts: 7
Joined: Mon Mar 12, 2018 10:35 am

Element colour attribute tracking

Post by nirs » Mon Mar 12, 2018 10:47 am

Hi,

I would like to run a test that tracks after some icon for a time period of one hour.
What I need to track in that hour is the color changes of this element and to see the changes in the log report at the end of the test.

So how should I do it? By code writing or if there's any other way?
A code example will be very helpful.

I've added a snapshot of the relevant element.

Thanks.
You do not have the required permissions to view the files attached to this post.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Element colour attribute tracking

Post by odklizec » Tue Mar 13, 2018 12:05 pm

Hi,

I'm afraid, you forgot to mention, which icon exactly do you want to validate/track? Could you please provide an xpath of the element in question?

In any case, you will most probably have to use some custom code to track the color changes? Most probably obtaining a certain pixel and validate its color value? I believe there were discussed some pixel validation techniques in the past? Check for example this post:
https://www.ranorex.com/forum/can-i-che ... tml#p37084
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Vega
Posts: 222
Joined: Tue Jan 17, 2023 7:50 pm

Re: Element colour attribute tracking

Post by Vega » Tue Mar 13, 2018 3:53 pm

Well, I see two easy ways to approach this. The first is by using the Get Value action, storing the pulled value in a var and doing something with that var like print it to the report. If you prefer to work in code, you could easily achieve the same thing with something like below:

Code: Select all

for (int i = 0, i < 3600; i++)
{
 Report.Info("Current color is: " + <element>.GetAttributeValue("<attribute name for color>").ToString());
Delay.Seconds(1);
}
The above code snippet will loop 3600 times (this is how many seconds are in an hour) and will print the current color. I would recommend only printing the color to the report if the color has changed since the last check as this will currently print 3600 times to the report.... it is a bit much but this is just an example. Alternatively, you could also adjust the delay to check once a minute / every 10 minutes / etc. Really depends on your specific scenario