Working with controls of class Edit and a role of Text : Automation API

Working with controls of class Edit and a role of Text

Class library usage, coding and language questions.

Working with controls of class Edit and a role of Text

Postby creynolds » Thu Jun 19, 2008 6:28 pm

I come accross this a lot where I have a control that is of the Edit Class and I'm always setting the focus of the control and then sending keystrokes to the app to add text to the text field of the edit control. Is there a better way? Why isn't there a FindEdit method? Will FindTextBox work for the Edit control? I would like to just set the text of the control to what ever I would like instead of setting focus to the control and then sending keystrokes.

Thanks for you help
creynolds
 
Posts: 4
Joined: Tue Sep 18, 2007 4:45 pm
Location: USA

Postby Support Team » Fri Jun 20, 2008 1:27 pm

Will FindTextBox work for the Edit control?


Yes, you can find an edit box and set/get the text of it as follows:
(See the sample application RanorexVS2005Sample2)

Code: Select all
TextBox textBox = form.FindTextBox("textBox1");
if (textBox != null)
{
    textBox.Focus();
    textBox.Text = "Ranorex";
    text = textBox.Text;
}


Or you can also use the Element class:

Code: Select all
Element fileEditControl = openFileDialog.Element.FindChild(Role.Text,"File name:");
if( fileEditControl != null)
    fileEditControl.Value = "D:\\Ranorex\\Bin\\RanorexNet.dll";

Jenö
Ranorex Team
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria


Return to Automation API

Who is online

Users browsing this forum: No registered users and 0 guests