How to Get Background Colour of a Button

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
Deepak_Singh
Posts: 76
Joined: Fri Mar 14, 2014 2:37 pm

How to Get Background Colour of a Button

Post by Deepak_Singh » Tue Apr 01, 2014 7:21 am

Hi,

In my application I am clicking a button. And after that It highlights in "Blue" colour.
Now I want to verify whether the element is being highlighted in Blue.
How will I able to do that and could i also get the Colour of the Text.

For Eg: Login Button is present with white colour and after clicking it the background of the Button changes to Blue colour.
How can I do that? :?:

Please Help.

Thanks In Advance,
Deepak :D

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

Re: How to Get Background Colour of a Button

Post by odklizec » Tue Apr 01, 2014 7:44 am

Hi,

Does the button stays blue after it gets clicked (mouse down-mouse up events) or it changes its color back on mouse up event?

If there is no color property detected by Ranorex spy, then I think the only way would be to use the image comparison (unless you want to code up something more sophisticated using C#/VB.NET). Could you post a snapshot of the button?
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

Deepak_Singh
Posts: 76
Joined: Fri Mar 14, 2014 2:37 pm

Re: How to Get Background Colour of a Button

Post by Deepak_Singh » Tue Apr 01, 2014 8:30 am

Hi,
Nope the button background colour does not change after scrolling to different location.
I have attached the snapshot and via that you caould see that there are 2 buttons adjacent to each other

First button is "Equties": Text colour:-White and Background colour:Grey
Second button is "Fixed Income"(Clicked):-Text colour: White and Background Colour:Blue

Now I want to get Text Colour and Background Colour for both these buttons.

How will I be able to do the same ?

Thanks,
Deepak
Last edited by Deepak_Singh on Wed Apr 02, 2014 8:12 am, edited 1 time in total.

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

Re: How to Get Background Colour of a Button

Post by odklizec » Tue Apr 01, 2014 8:39 am

Hi, could you please create and post a Ranorex snapshot (as described >here<).
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

Deepak_Singh
Posts: 76
Joined: Fri Mar 14, 2014 2:37 pm

Re: How to Get Background Colour of a Button

Post by Deepak_Singh » Tue Apr 01, 2014 9:53 am

Hi,

I have attached the screenshot in Ranorex Screenshot format.

Regards,
Deepak
Last edited by Deepak_Singh on Wed Apr 02, 2014 8:11 am, edited 1 time in total.

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

Re: How to Get Background Colour of a Button

Post by odklizec » Tue Apr 01, 2014 10:28 am

As I've expected, there is no color property you are looking for. So the easiest thing you can try is to use the Image-based validation.
http://www.ranorex.com/support/user-gui ... html#c2581

I'm sure there could be coded a sophisticated way to detect and compare colors of individual pixels (using C#/VB .net code), but I'm afraid, I could not help you with this ;)
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

rajesh.rajnish
Posts: 1
Joined: Sun Nov 10, 2013 6:08 pm

Re: How to Get Background Colour of a Button

Post by rajesh.rajnish » Sat Apr 05, 2014 5:53 pm

If the button belongs to .net technology.
You can assign button to control class. Its a ranorex provided class.
Please explore ranorex control class. After assigning button to this class you will acces of all property define by developer.
I could have provided you example but I am not infront of system.

Deepak_Singh
Posts: 76
Joined: Fri Mar 14, 2014 2:37 pm

Re: How to Get Background Colour of a Button

Post by Deepak_Singh » Fri Apr 11, 2014 10:27 am

Hi rajesh-rajnish,

Please give us code when you are back to your system. :lol:

Regards,
Deepak :)

Deepak_Singh
Posts: 76
Joined: Fri Mar 14, 2014 2:37 pm

Re: How to Get Background Colour of a Button

Post by Deepak_Singh » Fri Apr 11, 2014 10:02 pm

As per ur suggestions i have understood that it has no colour property with this particular button.

But can i just check whether the button is highlighted or not?

Regards,
Deepak

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: How to Get Background Colour of a Button

Post by Support Team » Wed Apr 16, 2014 12:58 pm

Hello Deepak_Singh,

The easiest way to check whether the button is highlighted or not is as already mention from odklizec to use an image-based validation step

Regards,
Robert