Finding HtmlInputText using text next to it.

2 posts, 0 answers
  1. SD
    SD avatar
    62 posts
    Member since:
    Apr 2010

    Posted 06 Sep 2011 Link to this post

    Hi guys, 

    Sometimes it's easier to find (And then write into) an input text field by the text description next to it. 
    I've been using xpath for that ever since but tried to find a more elegant approach..
    The following is a pretty common design..
    <td>Reason waived</td>
    <input id="feeForm:reasonWaived" type="text" name="feeForm:reasonWaived"/>
    Tried this. The first element in the array is without a doubt the input element. The thing is, I was not able to use that element in a SetText method for instance...Any ideas ? 
        Element txtNextTohtmlInputText = Manager.ActiveBrowser.Find.ByContent("Reason Waived");
        Element htmlInputTextParent = txtNextTohtmlInputText.GetNextSibling();
        htmlInputTextParent.GetChildren().First();//The InputText field.
  2. Anthony
    Anthony avatar
    19 posts

    Posted 07 Sep 2011 Link to this post

    Hi Sd,

    Why not find the input element by its ID and set the text directly into that element?

    HtmlInputText input = Find.ByExpression<HtmlInputText>("id=feeForm:reasonWaived");
    input.Text = "New Text";

    All the best,
    the Telerik team
    Vote for Telerik Test Studio at the Annual Automation Honors Voting!
Back to Top