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

Focus a textbox

3 Answers 74 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Christoph
Top achievements
Rank 1
Christoph asked on 28 Mar 2013, 10:27 AM
Hey there,

I have one problem. I enter text in a textbox of a form. But this text wont be submitted. So i need to focus the textbox. Then it works. How can i focus that. I tought with a click in the input, but if i execute the test it doesnt executes the click. Only if i start the test with Selected steps, It works.

So can i focus the input like that?

Pages.FundClassCustomViews.ShortIDText.Focus();

But if i code that it answres with a exception. It expects a div and not a input... 

So can you help me?

Thanks and greetings Chris

3 Answers, 1 is accepted

Sort by
0
Boyan Boev
Telerik team
answered on 28 Mar 2013, 11:13 AM
Hi Christoph,

Your code should work without any problems. This is a correct way to set focus to an element.

Another way to set it is to click on the element with SimulateRealClick property set to true (see attached screen shot). That means that it affects the browser in the same way that a real user would affect the browser.

In order to assist you best please provide more detailed information:

1. Send us the execution log.

2. Please record a Jing video demonstrating the entire process, so we can better understand what is happening. 

3. Provide us with a copy of your test and access to your application so we can reproduce the issue on our end and give you a solution.

4. Alternatively you can take a Fiddler trace using FiddlerCap and send it to us in a zip file. Basically with that trace I'll try to "simulate" your app in order to reproduce the issue.

Hope to hear from you soon.

Greetings,
Boyan Boev
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Christoph
Top achievements
Rank 1
answered on 28 Mar 2013, 11:25 AM
Thanks for the fast answer Boyan.

I tried to to a realClick, but then the window scrolls the texinput to the top, but there is a fixed menu. So it clicks on a menupoint. Can i turn off that is scrolls to the top?

And here is the Failure Information of the coded Step:

Exception thrown executing coded step: '[References_CostumViewsReference_Validation_CodedStep] : Click 'ShortIDText''.
InnerException:
System.ArgumentException: Invalid tag name 'input' for this control. Control was expecting 'div'
   at ArtOfTest.WebAii.Controls.Control.CreateInstance[TControl](Element e, Boolean throwIfNull)
   at ArtOfTest.WebAii.ObjectModel.Element.As[TControl]()
   at ArtOfTest.WebAii.TestTemplates.HtmlElementContainer.Get[TControl](HtmlFindExpression expr)
   at ArtOfTest.WebAii.TestTemplates.HtmlElementContainer.Get[TControl](String[] clauses)
   at Man_Group.Pages.FundClassCustomViewsPage.get_ShortIDText() in c:\Users\machine_telerik2\Documents\Test Studio Projects\MAN 04.03.13\ManGroup\Pages.g.cs:line 14672
   at Man_Group.References__CostumViews_Reference__Validation.References_CostumViewsReference_Validation_CodedStep() in c:\Users\machine_telerik2\Documents\Test Studio Projects\MAN 04.03.13\ManGroup\CMS\PMS\PMS.CustomViews\References 'CostumViews.Reference' Validation.tstest.cs:line 216

regards Chris
0
Accepted
Boyan Boev
Telerik team
answered on 28 Mar 2013, 01:58 PM
Hi Christoph,

The error message you are getting is trying to say that Test Studio found an <input> element but it was expecting a <div> element instead.

The only really good solution to this problem is to delete and manually re-add the element so that Test Studio records it as an <input> element instead of a <div> element.

To manually add the element you want, you need to launch our recorder, manually navigate to the page in question then use Add to Project Elements using our Elements Menu. NOTE: The name of the element may change, so be prepared to update your code to account for the new name.

I recorded a short video as a demonstration.

And then use the coded step to focus it. 

To "disable" the scrolling in a click step with SimulateRealUser property set to true you just need to convert it to code and delete the line of code which is scrolling.

Here is another video that demonstrates it.

Hope this helps.

All the best,
Boyan Boev
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Christoph
Top achievements
Rank 1
Answers by
Boyan Boev
Telerik team
Christoph
Top achievements
Rank 1
Share this question
or