This is a migrated thread and some comments may be shown as answers.

How to insert numbers into an already populated TextBox in a RadNumericUpDown

3 Answers 59 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
gnuftw
Top achievements
Rank 2
gnuftw asked on 03 Jun 2015, 12:59 AM

I am working on testing passing keystrokes into a TextBox within a RadNumericUpDown control that is part of my WPF application. I am trying to insert a digit into a number already in a TextBox. Consider the following situation...

I have just typed the value 1000 into the TextBox while recording. Test Studio records my left mouse click that focuses in on the TextBox in a single step and records the typing of 1000 in the proceeding step. Now, I move focus away from the TextBox I just entered 1000 into by hitting the tab key.

I would like to add the digit 1 into the 1000 already present in the TextBox such that the value ends up being 10(1)00 or 10100. So I focus my cursor at the position in the TextBox between 10 and 00, type 1, hit tab, and set up a verification step to make sure the value in the TextBox has turned into 10100. Visually at this point in the recording, I see 10100 in the TextBox.

I then quit recording my application so I could execute it. When I execute it, it fails on the verification step because when I enter the 1 into the TextBox, it replaces the entire TextBox value from 1000 to 1. So instead of having 10100 in the TextBox, it has 1.

Is it possible for me to insert a digit into a TextBox value without bombing on the rest of it?

*It should be noted that I am simulating both real keystrokes and mouse clicks (not sure if this matters).*

Thanks!

~ Max

 

3 Answers, 1 is accepted

Sort by
0
Accepted
Cody
Telerik team
answered on 04 Jun 2015, 05:20 PM
Hi Max,

Why do you want to do this? It's a very strange automation scenario. To accomplish it requires a coded step to:
  1. Grab the current string
  2. Insert the new digit into the string
  3. Retype the modified string

string value = Applications.WPF_Demosexe.WPF_Controls_Examples__GridView_ChartView_ScheduleView_RichTextBox_Map_Code_Samples.TextboxTextbox.Text;
value = value.Insert(2, "1");
Applications.WPF_Demosexe.WPF_Controls_Examples__GridView_ChartView_ScheduleView_RichTextBox_Map_Code_Samples.TextboxTextbox.SetText(true, value, 10, 100, false);



Regards,
Cody
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
gnuftw
Top achievements
Rank 2
answered on 16 Jun 2015, 03:09 PM

We would like to do this so we can test all possible situations of user input to make sure text boxes and fields behave correctly.

Thanks for the coded step Cody.

~ Max

0
Cody
Telerik team
answered on 17 Jun 2015, 04:24 PM
Hi Max,

Keep in mind that what you're testing with this approach is the control itself placed on the web page rather than the business logic of your application. It's rarely worth the time to automate testing of the control. Even if you do discover a bug in the control, your developers will be unable to fix it. You will have to reach out to the vendor of the control to report the bug and request a fix.


Regards,
Cody
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
gnuftw
Top achievements
Rank 2
Answers by
Cody
Telerik team
gnuftw
Top achievements
Rank 2
Share this question
or