Page 1 of 1

Can Ranorex identify text colour on a website?

Posted: Wed Jul 30, 2014 12:30 pm
by Fergal
I want to record a test, that enters an incorrect value into a field of a web application and then verifies that the font colour has changed to red (because the value is incorrect).

Is it possible to use Ranorex, to verify the red font colour?

Thanks!

Re: Can Ranorex identify text colour on a website?

Posted: Thu Jul 31, 2014 4:17 pm
by Support Team
Hi Fergal,

Yes, this is possible. You need to get the specific style of the specific element in code. You can use a code similar to the following:
var yourHTMLElement= repo.YourRootElement.YourHTMLElement;      	
String color = yourHTMLElement.GetStyle("color"); // get the value of the specific css property
Validate.AreEqual("red", color);
Report.Info("Color: "+color);
Regards,
Markus

Re: Can Ranorex identify text colour on a website?

Posted: Fri Aug 01, 2014 10:53 am
by Fergal
Thanks for your reply Markus.

Is it possible to do this without writing a code module, i.e. through the recorder?

Re: Can Ranorex identify text colour on a website?

Posted: Mon Aug 04, 2014 3:12 pm
by Support Team
Hi Fergal,

It should be possible by using the Validate -> AttributeEqual action. As Match Name you can select color and as Match Value you can select the value:
ValidateColor.png
Please note that you also need to use "rgb(255, 0, 0)" in case the color CSS property is also set to "rgb(255, 0, 0)" instead of just red. So use the exact same value as used to define the color.

Regards,
Markus

Re: Can Ranorex identify text colour on a website?

Posted: Wed Aug 06, 2014 10:21 am
by Fergal
Thanks Markus, I will try that.