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

Xpath not recognized

1 Answer 62 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Piotr
Top achievements
Rank 1
Piotr asked on 20 Oct 2011, 03:23 PM
In the web app I am testing against I've got the element:

<form name="aspnetForm" id="aspnetForm" onsubmit="javascript:return WebForm_OnSubmit();" action="default.aspx" method="post" sizcache="10" sizset="0">

The following code:

Element element1 = Find.ById("aspnetForm");
Element element2 = Find.ByXPath("//form[@id='aspnetForm']");
Element element3 = Find.ByXPath("//form[@name='aspnetForm']");

returns element1 as correct found element, wheras element2 and element3 are nulls. What is the reason for that?

IE8, WinXP.

1 Answer, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 25 Oct 2011, 07:17 PM
Hello Piotr,

I created the same element in a sample page, and the following code passed:

Manager.LaunchNewBrowser();
ActiveBrowser.NavigateTo("c:\\html\\comma2.html");
 
Element e1 = Find.ById("aspnetForm");
Element e2 = Find.ByXPath("//form[@id='aspnetForm']");
Element e3 = Find.ByXPath("//form[@name='aspnetForm']");
 
Assert.IsNotNull(e1);
Assert.IsNotNull(e2);
Assert.IsNotNull(e3);
 

What are we doing differently?

All the best,
Anthony
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
Piotr
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Share this question
or