Find.ById gets wrong element

2 posts, 0 answers
  1. Thomas Sonnenschein
    Thomas Sonnenschein avatar
    27 posts
    Member since:
    Dec 2008

    Posted 11 Apr 2014 Link to this post

    Hello forum users,

      I have a problem, to find a button via id on my page. The button has the id "test" and is surrounded by a section with the id "testform".

    If I try to find my button with
    HtmlInputSubmit myButton = Find.ById<HtmlInputSubmit> ("test");

    I get null.
    If I try
    Element myButton = Find.ById ("test");

    I get the surrounding section instead of the button. Very annoying.

    It seems, that the Find.ById makes no exact search, but searches with contains, so that the first element, that contains my search text is found. It makes no different, if my form id is "testform" or "formtest"

    My Form:
    <section id="testform">
        @using (Html.BeginForm(new { ReturnUrl = ViewBag.ReturnUrl }))


    input type="submit" class="k-button" value="Click me" id="test" />


    PS: I'm using MVC 4.0 with razor syntax and .NET 4.0, VS 2010 Professional SP1, Telerik Testing Framework 2013.2

  2. Ivaylo
    Ivaylo avatar
    782 posts

    Posted 16 Apr 2014 Link to this post

    Hello Thomas,

    Please excuse me for the delayed reply.

    I am sorry you are experiencing this behavior. Using the sample provided I was not able to reproduce this behavior. It might be because I am using the code for the form only, however using the code below is not returning null:

    HtmlInputSubmit myButton = Find.ById<HtmlInputSubmit> ("test");

    Please consider upgrading and if the issue still reproduces please provide a reliable repro so I can investigate further.

    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top