userNametextbox.Text throws an error

Sep 20, 2010 at 12:27 PM














Why I am getting an error message when retrieving userNametextbox.Text? Is it a correct way? can someone please cofirm? Thanks.

TextBox userNametextbox = MainWindow.Get<TextBox>(SearchCriteria.ByText("User"




 string name = ""






val = userNametextbox.Text;





Sep 20, 2010 at 1:40 PM


what is the error mesage?. Maybe userNametextbox is null?


Sep 20, 2010 at 1:43 PM

It is not null, as I visually see the user name in the Username text box field. This is done using MainWindow.Enter(name). I have also tried to set the value using MainWIndow.SetValue( please let me know if this is not the correct way and how i can enter the data in the username text box field and get the value from the text field. Thanks

Sep 20, 2010 at 2:03 PM




normal way for Textboxes


TextBox box = window.Get<Textbox>(SerachCriteria........);


box.Enter("Hello"); //  like user enter using keyoard

box.BulkText = "Hello";




string value = box.Text;


if you set using the above way does the same Error occur?

have you checked that the textbox is enabled? Maybe your test is too fast;


What does the error say?



Sep 20, 2010 at 2:16 PM

I get the same error using the method you had described above. I have also set the Thread.Sleep (500); for some sleep time but stil the same results.. I do not know how to setup an appropriate error message but what i get is a Visual Studio Just-In-Time Debugger which appears with the message: An unhandled Microsoft.NET Framework exception occurred in MyProjectName.exe[4528]. (Is there a way I can get the appropriate error message? - This is too generic and does not help me in finding the actual cause of the problem?)Thanks again for your time.

Sep 20, 2010 at 2:29 PM



to verify the exception use a try catch, hope you will get a better message.

Seems to be a special problem. .Net 3.5 or  4? Latest White version?



Sep 20, 2010 at 2:43 PM

I have white binaries from 2.0 and .NET framework is 4. There is one thing i want to mention which i just noticed is if I use Enter name on the Textbox,it  throws and error as well. So to enter the text in the textbox I am calling Mainwindow.Enter( Do you know why I can't enter using Textvox.Enter() and can only use MainWindow.Enter(). Thanks

Sep 20, 2010 at 3:08 PM

The error i get here is Object reference not set to an instance of an object and this error appears when using Textbox.Enter("ABC");

Sep 20, 2010 at 3:56 PM

Can you debug and put a break point on the line where u try to initialize the control eg. TextBox box = window.Get<Textbox>("texboxname"); ?

See if this returns a null object? if not then you should be able to do box.enter("abcedfg...")



Sep 21, 2010 at 2:35 PM

Thanks for the infomation. Yes, it was the problem that it was returning a null object. I have fixed it using Automation id instead of text. Thanks again.