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

Telerik XPATH implementation bug v2

1 Answer 90 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 07 Feb 2012, 02:46 PM
Hi

I wrote a while back about some problems I'm experiencing with Teleriks implementation of xpath. But before i didn't have a live website i could reference, I do now.

HtmlFindExpression h1 = new HtmlFindExpression("xpath=//h1");
.Find.ByExpression(h1)


The above will result in this error:
The ':' character, hexadecimal value 0x3A, cannot be included in a name.

When run against this website:
http://www.tradingfloor.com/posts/central-banks-deliver-end-of-month-boost--1013237813


NOTE:
This works as intended if i check it against Selenium.

1 Answer, 1 is accepted

Sort by
0
Accepted
Cody
Telerik team
answered on 10 Feb 2012, 01:09 AM
Hello,

I have determined this is not a test studio bug. There is something wrong with your website such that the .NET framework is choking on that webpage. I created this pure .NET code to read and parse your website:

// Create the WebRequest object we'll use for sending the request
request.Method = "GET";
 
WebResponse response = request.GetResponse();
// Verify the status code is OK
Assert.AreEqual<string>("OK", ((HttpWebResponse)response).StatusDescription);
 
Stream responseStream = response.GetResponseStream();
XmlDocument doc = new XmlDocument();
doc.Load(responseStream);
 
XmlNodeList h1tags = doc.SelectNodes("//h1");
Log.WriteLine("Found " + h1tags.Count.ToString() + " nodes");

This pure .NET code is throwing this error on the doc.Load line:

System.Xml.XmlException: The ';' character, hexadecimal value 0x3B, cannot be included in a name. Line 6, position 263.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
   at System.Xml.XmlTextReaderImpl.Throw(Int32 pos, String res, String[] args)
   at System.Xml.XmlTextReaderImpl.ParseElement()
   at System.Xml.XmlTextReaderImpl.ParseElementContent()
   at System.Xml.XmlTextReaderImpl.Read()
   at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
   at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
   at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
   at System.Xml.XmlDocument.Load(XmlReader reader)
   at System.Xml.XmlDocument.Load(Stream inStream)
   at MySampleTests.ScratchTest.ScratchTest_CodedStep() in C:\Users\gibson\Documents\Visual Studio 2010\Projects\MySampleTests\MySampleTests\ScratchTest.tstest.cs:line 62

I do not know what/where the problem is but this proves there's some invalid HTML contained on your webpage causing .NET to choke on it. Once you fix your website then the XPath will work as expected.

All the best,
Cody
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Martin
Top achievements
Rank 1
Answers by
Cody
Telerik team
Share this question
or