BackColor Attribute? : Automation API

BackColor Attribute?

Class library usage, coding and language questions.

BackColor Attribute?

Postby bsing » Tue Feb 07, 2012 6:45 am

Hi,

I am using Ranorex 3.0.5.

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

B
bsing
 
Posts: 39
Joined: Tue Feb 07, 2012 6:25 am

Re: BackColor Attribute?

Postby sham526 » Tue Feb 07, 2012 8: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)
sham526
 
Posts: 17
Joined: Wed Jul 07, 2010 8:12 am
Location: Hyderabad(INDIA)

Re: BackColor Attribute?

Postby Support Team » Tue Feb 07, 2012 8: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
User avatar
Support Team
Site Admin
 
Posts: 4837
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: BackColor Attribute?

Postby bsing » Wed Feb 08, 2012 8:50 am

The documentation indicates that BackColor is only supported by RanorexPro.
bsing
 
Posts: 39
Joined: Tue Feb 07, 2012 6:25 am

Re: BackColor Attribute?

Postby Support Team » Wed Feb 08, 2012 6: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
User avatar
Support Team
Site Admin
 
Posts: 4837
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: BackColor Attribute?

Postby bsing » Fri Feb 17, 2012 5: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"
bsing
 
Posts: 39
Joined: Tue Feb 07, 2012 6:25 am

Re: BackColor Attribute?

Postby sham526 » Fri Feb 17, 2012 7: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
sham526
 
Posts: 17
Joined: Wed Jul 07, 2010 8:12 am
Location: Hyderabad(INDIA)

Re: BackColor Attribute?

Postby bsing » Fri Feb 17, 2012 8:04 am

Are you able to translate your vb code to C#? .... don't want to go down the vb path ... sorry
bsing
 
Posts: 39
Joined: Tue Feb 07, 2012 6:25 am

Re: BackColor Attribute?

Postby Support Team » Fri Feb 17, 2012 10: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
User avatar
Support Team
Site Admin
 
Posts: 4837
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: BackColor Attribute?

Postby bsing » Mon Feb 20, 2012 1:27 am

Is InputTag used for web pages/documents?

I am using a Windows Application.
bsing
 
Posts: 39
Joined: Tue Feb 07, 2012 6:25 am

Re: BackColor Attribute?

Postby Support Team » Tue Feb 21, 2012 12:21 pm

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
User avatar
Support Team
Site Admin
 
Posts: 4837
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: BackColor Attribute?

Postby bsing » Wed Feb 29, 2012 8:05 am

Attached snapshot of mandatory field
Attachments
mandField.rxsnp
(187.93 KiB) Downloaded 5 times
bsing
 
Posts: 39
Joined: Tue Feb 07, 2012 6:25 am

Re: BackColor Attribute?

Postby Support Team » Wed Feb 29, 2012 6: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
User avatar
Support Team
Site Admin
 
Posts: 4837
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: BackColor Attribute?

Postby bsing » Thu Mar 01, 2012 12:53 am

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??
bsing
 
Posts: 39
Joined: Tue Feb 07, 2012 6:25 am

Re: BackColor Attribute?

Postby Ciege » Thu Mar 01, 2012 1: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...
User avatar
Ciege
 
Posts: 965
Joined: Thu Oct 16, 2008 7:46 pm
Location: Arizona, USA

Next

Return to Automation API

Who is online

Users browsing this forum: No registered users and 0 guests