How can we input value to a Textbox using White ?

Oct 15, 2012 at 2:37 PM

How can we input value to a Textbox using White ?

I am new to White and i am doing some RnD to findout if i can Automate the testing of my Application.

I have also one doubt - If i use AutomationID to identify a textbox, Will the code run everytime in different machines or the AutomationID of a object is always changing for the same object ?

Oct 15, 2012 at 3:59 PM

Hi

 

the AutomationId can change, but should not.

 

If the developer makes a good job the AutomationID is fixed and not localized.

 

example

 

Window main = Application.GetWindow("MainWindow");

TextBox box = main.Get<TextBox>(SearchCriteria.ByAutomationID("theID");

box.BulkText = "My simple Text";

//or

box.Enter("Some Text");

 

 

Throndorin

 

 

Oct 16, 2012 at 11:12 AM
Edited Oct 16, 2012 at 11:19 AM

Hi Throndorin,

can you please let me know which property should be set by developer so that i always get the same Automation ID.

I have 5 Textbox in a window. 4 textbox always give a same AutomationID everytime

but 1 textbox gives a Different AutomationID that is in Integer.

 

I dont get the Name Property also for the Textbox (DevExpress.XtraEditors.TextEdit): Following is the properties i get for the textbox

 Identification
    ClassName:    "WindowsForms10.EDIT.app.0.33c0d9d"
    ControlType:   "ControlType.Edit"
    Culture:    "(null)"
    AutomationId:   "1117132"
    LocalizedControlType: "edit"
    Name:     ""
    ProcessId:    "5428 (Softmar.nTier.Alerts.Client)"
    RuntimeId:    "42 1117132"
    IsPassword:    "False"
    IsControlElement:  "True"
    IsContentElement:  "True"

Dec 12, 2012 at 4:15 AM

 

Textbox is idendified but text is not set to texbox using any of the following function:

1.  box.BulkText = "some text"

2. box.Enter("Some Text");

Please help....

Following is my piece of code

--------------------------------------

Window main = Application.GetWindow("MainWindow");

TextBox box = main.Get<TextBox>(SearchCriteria.ByAutomationID("theID");

box.BulkText = "My simple Text";

//or

box.Enter("Some Text");

Dec 13, 2012 at 7:48 AM

Hi

you can  try to use class Keyboard to enter text

 

first click on the text box than use Keyboard.Enter("") or AttachedKeyboard (form class Window)

 

Throndorin

Jan 10, 2013 at 10:34 AM
Edited Jan 10, 2013 at 11:04 AM

Itried with following code but failed. Able to click in textbox. Nothing is entered in textbox even after code executes

 

 

White.Core.InputDevices.AttachedKeyboard keyboard = win.Keyboard;
Thread.Sleep(500);
TextObj.Focus();
TextObj.RaiseClickEvent();
keyboard.Enter("Harriet");

 

Jan 10, 2013 at 10:39 AM

White.Core.InputDevices.AttachedKeyboard keyboard = win.Keyboard;
Thread.Sleep(500);
TextObj.Focus();
TextObj.RaiseClickEvent();
keyboard.Enter("Harriet");