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

Find.ById gets wrong element

1 Answer 70 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Thomas Sonnenschein
Top achievements
Rank 2
Thomas Sonnenschein asked on 11 Apr 2014, 09:18 AM
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">
   
<h2>Headline</h2>
    @using (Html.BeginForm(new { ReturnUrl = ViewBag.ReturnUrl }))

    {

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

</
section>

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

Greetings
  Thomas

1 Answer, 1 is accepted

Sort by
0
Ivaylo
Telerik team
answered on 16 Apr 2014, 08:32 AM
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.

Regards,
Ivaylo
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
Thomas Sonnenschein
Top achievements
Rank 2
Answers by
Ivaylo
Telerik team
Share this question
or