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

Programmatically Fill in a TextBox

7 Answers 112 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Nate
Top achievements
Rank 1
Nate asked on 24 Mar 2011, 10:52 PM
Hello,
         I was wondering if someone could help me out how to programmatically fill in a Webform's textbox using the QA Edition of WebUI. A simple example should get me up and going. 

7 Answers, 1 is accepted

Sort by
0
Benjamin
Top achievements
Rank 1
answered on 25 Mar 2011, 08:49 AM

you could do it this way depending on the text box can handle html tags or not.

NO HTML:
Pages.PageElemennt.ConTrolElement.Text = "test\nTesting";

HTML:
Pages.PageElemennt.ConTrolElement.Html = "test <BR />Testing";

there is proberly better ways to get the same result but this works atleast for small quick pices of text.


Regards
Ben

0
Nate
Top achievements
Rank 1
answered on 25 Mar 2011, 02:20 PM
Ben,
         Thanks for the tip and how do you retrieve the "Pages.PageElemennt.ConTrolElement"  element programmitically such that WebUI will recognize it as a variable? I know I can right click on it do "extract" but I'm looking for a way to do this in code.
0
Benjamin
Top achievements
Rank 1
answered on 25 Mar 2011, 02:35 PM
Hi Nate.

as far as i know the only way to add an element to the Project element tree is by navigating to the test page and then either make a verification on that ellement og select add to elements.

so in essense "Pages.PageElemennt.ConTrolElement" can be read like.

Pages. (as far as i know is always named this)
PageElement (title of the page the element was recorded on or renamed to afterwords)
ControlElement (the acual element that you want to interact with)

so if i whanted to enter  "domain\nate" in to a login field on a html page titled "Login" it would look like this in a coded step

Pages.Loginpage.Logininput.Text = "domain\nate";

i hope that clarifyes it a bit
or we might just have ti get someone from the telerik team to explain it better then i can

Regards
Ben
0
Nate
Top achievements
Rank 1
answered on 25 Mar 2011, 04:19 PM
Right, thanks for the explanation. I'll create a support case to see if I can get a response from someone official to respond back.
0
Nate
Top achievements
Rank 1
answered on 25 Mar 2011, 06:36 PM
I figured it out with a little bit of help ;-).

HtmlInputText LoginIDinput = Find.ById<HtmlInputText>(

 

"LoginID");
LoginIDinput.Text = "string";

This is where the text box has a unique ID of "LoginID"

 

0
Accepted
Cody
Telerik team
answered on 25 Mar 2011, 08:31 PM
Hi Nate,

Yes that is the best approach when you need to fill it the fields via code.

All the best,
Cody
the Telerik team
0
Nate
Top achievements
Rank 1
answered on 25 Mar 2011, 08:32 PM
Thanks for the tips in the case Cody. Keep up the good work!
Tags
General Discussions
Asked by
Nate
Top achievements
Rank 1
Answers by
Benjamin
Top achievements
Rank 1
Nate
Top achievements
Rank 1
Cody
Telerik team
Share this question
or