Page 1 of 1

How to Get Background Colour of a Button

Posted: Tue Apr 01, 2014 7:21 am
by Deepak_Singh
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

Re: How to Get Background Colour of a Button

Posted: Tue Apr 01, 2014 7:44 am
by odklizec
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?

Re: How to Get Background Colour of a Button

Posted: Tue Apr 01, 2014 8:30 am
by Deepak_Singh
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

Re: How to Get Background Colour of a Button

Posted: Tue Apr 01, 2014 8:39 am
by odklizec
Hi, could you please create and post a Ranorex snapshot (as described >here<).

Re: How to Get Background Colour of a Button

Posted: Tue Apr 01, 2014 9:53 am
by Deepak_Singh
Hi,

I have attached the screenshot in Ranorex Screenshot format.

Regards,
Deepak

Re: How to Get Background Colour of a Button

Posted: Tue Apr 01, 2014 10:28 am
by odklizec
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 ;)

Re: How to Get Background Colour of a Button

Posted: Sat Apr 05, 2014 5:53 pm
by rajesh.rajnish
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.

Re: How to Get Background Colour of a Button

Posted: Fri Apr 11, 2014 10:27 am
by Deepak_Singh
Hi rajesh-rajnish,

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

Regards,
Deepak :)

Re: How to Get Background Colour of a Button

Posted: Fri Apr 11, 2014 10:02 pm
by Deepak_Singh
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

Re: How to Get Background Colour of a Button

Posted: Wed Apr 16, 2014 12:58 pm
by Support Team
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