如何使用 WatiN 属性获取完整的 HTML 内容 [英] How to get complete HTML content using WatiN properties

查看:30
本文介绍了如何使用 WatiN 属性获取完整的 HTML 内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 ASP.NET Web 应用程序中使用 WatiN 工具.我想要我启动的 IE 的完整 HTML 内容.WatiN 中的 IE 类提供了一个名为Html"的属性,它仅返回 HTML 源的正文内容.获得头部标签内容的方法是什么?

I am using the WatiN tool in my ASP.NET web application. I want the complete HTML content of the IE which I had launched. IE class in WatiN provides a property called "Html", which returns only the body content of the HTML source. What is the way to get the head tag content also along with it?

这是我的源代码:

IE myIE = new IE();
 myIE.GoTo("http://wsspg.dequecloud.com/worldspace/wsservice/eval/checkCompliance.jsp");
 myIE.TextField(Find.ByName("txtUrl")).TypeText("http://rockycode.com/blog/watin-and-xpath-support/");
 myIE.Button(Find.ByValue("Generate Report")).Click();
 myIE.WaitForComplete();
 var myHtml = myIE.Html;

推荐答案

不知道为什么,但 WatiN 不让您直接访问 head 或 html 元素.但你仍然可以找到它们!

Don't know why, but WatiN doesn't give you direct access to the head or html elements. But you can still get to them!

using (IE myIE = new IE())
{
    myIE.GoTo("http://wsspg.dequecloud.com/worldspace/wsservice/eval/checkCompliance.jsp");
    myIE.TextField(Find.ByName("txtUrl")).TypeText("http://rockycode.com/blog/watin-and-xpath-support/");
    myIE.Button(Find.ByValue("Generate Report")).Click();
    myIE.WaitForComplete();
    string myHtml = myIE.Body.Parent.OuterHtml;
}

这篇关于如何使用 WatiN 属性获取完整的 HTML 内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆