Element colour attribute tracking

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

Element colour attribute tracking

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


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.

(895.34 KiB) Downloaded 103 times

User avatar
Ranorex Guru
Ranorex Guru
Posts: 7102
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


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

User avatar
Certified Professional
Certified Professional
Posts: 222
Joined: Mon Jul 11, 2016 2:15 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());
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