Can Ranorex identify text colour on a website?

Ask general questions here.
Fergal
Certified Professional
Certified Professional
Posts: 298
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Can Ranorex identify text colour on a website?

Post by Fergal » Wed Jul 30, 2014 12:30 pm

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!

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Can Ranorex identify text colour on a website?

Post by Support Team » Thu Jul 31, 2014 4:17 pm

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
.
Image

Fergal
Certified Professional
Certified Professional
Posts: 298
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Re: Can Ranorex identify text colour on a website?

Post by Fergal » Fri Aug 01, 2014 10:53 am

Thanks for your reply Markus.

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Can Ranorex identify text colour on a website?

Post by Support Team » Mon Aug 04, 2014 3:12 pm

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
ValidateColor.png (2.71 KiB) Viewed 1675 times
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
.
Image

Fergal
Certified Professional
Certified Professional
Posts: 298
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Re: Can Ranorex identify text colour on a website?

Post by Fergal » Wed Aug 06, 2014 10:21 am

Thanks Markus, I will try that.