Page 1 of 2

BackColor Attribute?

Posted: Tue Feb 07, 2012 5:45 am
by bsing
Hi,

I am using Ranorex 3.0.5.

Is there a way to access the BackColor property of a text box?

B

Re: BackColor Attribute?

Posted: Tue Feb 07, 2012 7:25 am
by sham526
Try the below code.. 8)

Dim input_text As InputTag = layer_table.FindSingle(Of InputTag)("./input[1]")

MsgBox(input_text.GetStyle("color").ToString)

Re: BackColor Attribute?

Posted: Tue Feb 07, 2012 7:26 am
by Support Team
Hi,

Have look at the Ranorex API documentation of a textbox.
The property BackColor is also provided here, you can set/get the value of BackColor.

Regards,
Martin
Ranorex Support Team

Re: BackColor Attribute?

Posted: Wed Feb 08, 2012 7:50 am
by bsing
The documentation indicates that BackColor is only supported by RanorexPro.

Re: BackColor Attribute?

Posted: Wed Feb 08, 2012 5:15 pm
by Support Team
Hi,
bsing wrote:The documentation indicates that BackColor is only supported by RanorexPro.
Sorry, but martin has posted you the wrong link. This is the right link http://www.ranorex.com/Documentation/Ra ... eValue.htm

And here you have the sample code:
Text yourTextBox = "RxPath to your Textbox";            	
var color = yourTextBox.Element.GetAttributeValue("BackColor");
Regards,
Peter
Ranorex Team

Re: BackColor Attribute?

Posted: Fri Feb 17, 2012 4:03 am
by bsing
I tried your code ... and the first line works (I can get a valid reference to Text) .. but the 2nd line doesn't work for me (get a null returned) when trying to get "BackColor"

Re: BackColor Attribute?

Posted: Fri Feb 17, 2012 6:36 am
by sham526
bsing have to tried my piece of code

Dim input_text As InputTag = layer_table.FindSingle(Of InputTag)("./input[1]")
Dim color as string = input_text.GetStyle("backcolor").ToString

Re: BackColor Attribute?

Posted: Fri Feb 17, 2012 7:04 am
by bsing
Are you able to translate your vb code to C#? .... don't want to go down the vb path ... sorry

Re: BackColor Attribute?

Posted: Fri Feb 17, 2012 9:09 am
by Support Team
Hi

The C# version of bsing's vb code would be

Code: Select all

InputTag input_text = someTableTag.FindSingle<InputTag>("./input[1]");
string color = input_text.GetStyle("backcolor").ToString();
Regards,
Martin
Ranorex Support Team

Re: BackColor Attribute?

Posted: Mon Feb 20, 2012 12:27 am
by bsing
Is InputTag used for web pages/documents?

I am using a Windows Application.

Re: BackColor Attribute?

Posted: Tue Feb 21, 2012 11:21 am
by Support Team
Hi,
Is InputTag used for web pages/documents?
Yes, it is used for web pages as it is a html tag.
Would it be possible to send us a Ranorex Snapshot file of the specific control?
Following link will show you how to generate a snapshot file:
http://www.ranorex.com/support/user-gui ... files.html

Regards,
Markus
Ranorex Support Team

Re: BackColor Attribute?

Posted: Wed Feb 29, 2012 7:05 am
by bsing
Attached snapshot of mandatory field

Re: BackColor Attribute?

Posted: Wed Feb 29, 2012 5:29 pm
by Support Team
Hi,

to get your background color out of your control you can use following code snippet:
Text text = "/form[@controlname='frmMain']/container/container/element/container/container/text[@controlname='txtDetails']";
Color color = (Color) text.As<Control>().GetPropertyValue("BackColor");
Regards,
Tobias
Ranorex Support Team

Re: BackColor Attribute?

Posted: Wed Feb 29, 2012 11:53 pm
by bsing
I tried using this code, but the 'GetPropertyValue' method was not available.

I got the error after compiling 'System.Windows.Forms.Control' does not contain a definition for 'GetPropertyValue' .... etc.

I am using Ranorex v3.0.5 .... do I need to upgrade to say 3.2.1??

Re: BackColor Attribute?

Posted: Thu Mar 01, 2012 12:14 am
by Ciege
Try declaring your Text object as Ranorex.Text.

Code: Select all

Ranorex.Text text = "/form[@controlname='frmMain']/container/container/element/container/container/text[@controlname='txtDetails']";   
Color color = (Color) text.As<Control>().GetPropertyValue("BackColor");