Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Automated Testing and WebUI Test Studio > Telerik Testing Framework > Text doesn't appear in the Input field
These forums are read-only and serve as an archive for the previous versions of WebUI Test Studio.
For the current forums please go to the Automated Testing and WebUI Test Studio Forums

Not answered Text doesn't appear in the Input field

Feed from this thread
  • A911 avatar

    Posted on Mar 25, 2010 (permalink)

    I use a method SendString to put the value in the Input field.
    I find the Input field, set the mouse cursor in the field and then call the method SendString, but it's ... empty.

    My method is
    public void SetValueinFiltertotheField(string text) 
                { 
                    HtmlInputText textfield = new HtmlInputText( 
                        _frame.Find.ByParam(SummaryTable.SerializedElements["OperationItems"], TRYCOUNT)); 
                    textfield.MouseClick(MouseClickType.LeftClick);; 
                    Manager.Current.Desktop.KeyBoard.SendString(text); 
                } 
    "OperationItems" element is
      <FindParamItem key="OperationItems"
        <FindParam TagName="input" XPath="" NodeIndexPath="" Type="AttributesOnly" ContentType="TextContent" ContentValue="" TagOccurrenceIndex="-1"
          <Attributes> 
            <iAttribute Name="id" Value="operationItems" /> 
          </Attributes> 
        </FindParam> 
      </FindParamItem> 
    SOS! I've no idea why it's not working.



  • Cody Cody admin's avatar

    Posted on Mar 25, 2010 (permalink)

    Hello A911,

    First, let me ask what would be wrong with simply straight setting the text of your input field? Do you really need to simulate keyboard typing? You can set the text of your input text field directly with code like this:

    public void SetValueinFiltertotheField(string text)
    {
        HtmlInputText textfield = new HtmlInputText(
            _frame.Find.ByParam(SummaryTable.SerializedElements["OperationItems"], TRYCOUNT));
        textfield.Text = text;
    }

    The reason your code isn't working as expected is that textfield.MouseClick sends a click event directly to the DOM of the browser. It doesn't change/set the input focus at all. What you need is to do a desktop mouse click instead using code like this:

    public void SetValueinFiltertotheField(string text)
    {
        HtmlInputText textfield = new HtmlInputText(
            _frame.Find.ByParam(SummaryTable.SerializedElements["OperationItems"], TRYCOUNT));
        //textfield.MouseClick(MouseClickType.LeftClick);
        Manager.Desktop.Mouse.Click(MouseClickType.LeftClick, textfield.GetRectangle());
        Manager.Current.Desktop.KeyBoard.SendString(text);
    }

    The above code will actually move the mouse cursor to the middle of your input textbox and then simulate a windows mouse click at the current cursor position. That will force input focus to be on input textbox. Then the SendString will work as expected.

    All the best,
    Cody
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

  • A911 avatar

    Posted on Apr 1, 2010 (permalink)

    Thanks a lot for your help. But unfortunately the problem still exists. I used what you advise but it didn't help. We run the tests on virtual machines and I can see how the methods finds the field, the next one sets the cursor here, but the method which simulates keyboard typing doesn't type the digits in the field (FYI: I need to use only the method simulates keyboard typing). I also tried the method KeyPress but I got the same negative result.

    I hope you can help me, because I've no idea how to fix this problem :(

    I'm looking forward to your reply. Thank you!

  • Cody Cody admin's avatar

    Posted on Apr 2, 2010 (permalink)

    Hi Alenka,

    Ok, since that didn't work as expected it's time to do some troubleshooting. Questions to answered are:

    • Is the mouse moving and clicking on the right point? You can find out by setting a breakpoint on the SendString line and executing up to this breakpoint. When VS hits the breakpoint, you should be able to see where the mouse cursor is. It should be in the middle of the input box. If it isn't we need to figure out where did it go and why it didn't move to the right location.
    • Does the input box have focus? When VS hits the breakpoint, it may take focus away automatically. Click in the title bar of the IE browser window then type some characters. Do they go into the right input box? If not then the focus didn't get set to the right location.
    • Is SendString working in your VM? You can test this by writing code that launches Notepad and then use the SendString function. If it's working you'll see the characters typed into Notepad.

    Let me know what you discover in your debugging and we'll go from there.

    Best wishes,
    Cody
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Automated Testing and WebUI Test Studio > Telerik Testing Framework > Text doesn't appear in the Input field
Related resources for "Text doesn't appear in the Input field"

WebAii Framework Features  |  Documentation |  Videos  |  Webinars  |  Automated Testing Tools  ]