예제 #1
0
        public static HtmlDocumentAssertion CanGetBasicHtmlDocument(Uri url)
        {
            return(WebAssert.NoWebExceptions(() =>
            {
                HtmlDocument html = url.GetHtmlDocument();
                Assert.IsNotNull(html);

                HtmlNode titleNode = html.DocumentNode.SelectSingleNode("/html/head/title");
                Assert.IsNotNull(titleNode, "Page must contain title element");
                Assert.IsNotNullOrEmpty(titleNode.InnerText, "Page title must not be empty");

                return new HtmlDocumentAssertion(html);
            }));
        }
예제 #2
0
        public static XmlDocumentAssertion CanGetBasicXHtmlDocument(Uri url)
        {
            return(WebAssert.NoWebExceptions(() =>
            {
                XmlDocument xml = url.GetXmlDocument();
                Assert.IsNotNull(xml);

                XmlNode titleNode = xml.SelectSingleNode("/html/head/title");
                Assert.IsInstanceOf <XmlElement>(titleNode, "Page must contain title element");
                Assert.IsNotNullOrEmpty(((XmlElement)titleNode).InnerText, "Page title must not be empty");

                return new XmlDocumentAssertion(xml);
            }));
        }