How to read value from Custom Control

Oct 14, 2010 at 8:18 AM

Hi,

I am new to white. I have a custom control  which has an automation ID.

I am able to access the custom control and enter values in it.

This custom control has a Text box in it. This also has an automation ID.

How do I read the value entered in the custom control. Here numPulseInterval is the automation ID for the custom control. For the text box in the custom control the automation ID is "aWGNumericTextBox1"

For entering the value in the custom control my code is given below

UIItem

numpulint = (UIItem)window.Get(SearchCriteria.ByAutomationId("numPulseInterval"));  

numpulint.Click();

numpulint.Enter(

"333333");

Thanks for the help,

Kavin

 

Oct 14, 2010 at 11:53 AM

Hi

I think the custom control is a container right, a numeric up and down I think ?

and in fact you enter the value to the Textbox inside the custom control right?

 

so try

 

UIItem numpulint = (UIItem)window.Get(SearchCriteria.ByAutomationId("numPulseInterval")); 

TextBox box = numpulint.Get<Textbox>(SearchCriteria.ByAutomationID("aWGNumericTextBox1");

if box is null this way try

 

AutomationElement element = numpulint.GetElement(SearchCriteria.ByAutomationID("aWGNumericTextBox1");

TextBox box = new TextBox(element, numpulint.ActionListener);



 

from box you can read with box.Text or

 

Set text with EnterValue or BulkText = "Text"

 

Throndorin

 


 

 

 

 

 

Oct 14, 2010 at 4:35 PM
Thankyou very much Thondorin.
 
Yes the the custom control is a container , 
but they have disabled the numeric up and down buttons in the control
and yes we enter the value to the Textbox inside the custom control right.
 
I tried the below and I got NULL so I tried the second suggestion given by you
UIItem numpulint = (UIItem)window.Get(SearchCriteria.ByAutomationId("numPulseInterval")); 

TextBox box = numpulint.Get<Textbox>(SearchCriteria.ByAutomationID("aWGNumericTextBox1");

Code that worked is given below

AutomationElement element = numpulint.GetElement(SearchCriteria.ByAutomationID("aWGNumericTextBox1");

TextBox box = new TextBox(element, numpulint.ActionListener);

from box I could read the value using box.Text