BackColor Attribute?

Class library usage, coding and language questions.
bsing
Posts: 81
Joined: Tue Feb 07, 2012 5:25 am

BackColor Attribute?

Post by bsing » Tue Feb 07, 2012 5:45 am

Hi,

I am using Ranorex 3.0.5.

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

B

sham526
Posts: 34
Joined: Wed Jul 07, 2010 7:12 am
Location: Hyderabad(INDIA)

Re: BackColor Attribute?

Post by sham526 » Tue Feb 07, 2012 7:25 am

Try the below code.. 8)

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

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

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

Re: BackColor Attribute?

Post by Support Team » Tue Feb 07, 2012 7:26 am

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

bsing
Posts: 81
Joined: Tue Feb 07, 2012 5:25 am

Re: BackColor Attribute?

Post by bsing » Wed Feb 08, 2012 7:50 am

The documentation indicates that BackColor is only supported by RanorexPro.

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

Re: BackColor Attribute?

Post by Support Team » Wed Feb 08, 2012 5:15 pm

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

bsing
Posts: 81
Joined: Tue Feb 07, 2012 5:25 am

Re: BackColor Attribute?

Post by bsing » Fri Feb 17, 2012 4:03 am

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"

sham526
Posts: 34
Joined: Wed Jul 07, 2010 7:12 am
Location: Hyderabad(INDIA)

Re: BackColor Attribute?

Post by sham526 » Fri Feb 17, 2012 6:36 am

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

bsing
Posts: 81
Joined: Tue Feb 07, 2012 5:25 am

Re: BackColor Attribute?

Post by bsing » Fri Feb 17, 2012 7:04 am

Are you able to translate your vb code to C#? .... don't want to go down the vb path ... sorry

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

Re: BackColor Attribute?

Post by Support Team » Fri Feb 17, 2012 9:09 am

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

bsing
Posts: 81
Joined: Tue Feb 07, 2012 5:25 am

Re: BackColor Attribute?

Post by bsing » Mon Feb 20, 2012 12:27 am

Is InputTag used for web pages/documents?

I am using a Windows Application.

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

Re: BackColor Attribute?

Post by Support Team » Tue Feb 21, 2012 11:21 am

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

bsing
Posts: 81
Joined: Tue Feb 07, 2012 5:25 am

Re: BackColor Attribute?

Post by bsing » Wed Feb 29, 2012 7:05 am

Attached snapshot of mandatory field
Attachments
mandField.rxsnp
(187.93 KiB) Downloaded 228 times

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

Re: BackColor Attribute?

Post by Support Team » Wed Feb 29, 2012 5:29 pm

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

bsing
Posts: 81
Joined: Tue Feb 07, 2012 5:25 am

Re: BackColor Attribute?

Post by bsing » Wed Feb 29, 2012 11:53 pm

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??

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: BackColor Attribute?

Post by Ciege » Thu Mar 01, 2012 12:14 am

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");  
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...