首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WatiN: MsHtmlBrowser不会TypeText

WatiN: MsHtmlBrowser不会TypeText
EN

Stack Overflow用户
提问于 2010-01-21 23:17:37
回答 1查看 646关注 0票数 0

从WatiN网站:

代码语言:javascript
复制
  // Open a new Internet Explorer window and
  // goto the google website.
  IE ie = new IE("http://www.google.com");

  // Find the search text field and type Watin in it.
  ie.TextField(Find.ByName("q")).TypeText("WatiN");

  // Click the Google search button.
  ie.Button(Find.ByValue("Google Search")).Click();

  // Uncomment the following line if you want to close
  // Internet Explorer and the console window immediately.
  //ie.Close();

上面的示例运行得很好。但是,由于我不想打开浏览器窗口,因此我将上面的代码修改为使用MsHtmlBrowser:

代码语言:javascript
复制
        // goto the google website.
        var ie = new MsHtmlBrowser();
        ie.GoTo("http://www.google.com");
        // Find the search text field and type Watin in it.
        ie.TextField(Find.ByName("q")).TypeText("WatiN");

        // Click the Google search button.
        ie.Button(Find.ByValue("Google Search")).Click();

TypeText行抛出了一个异常。知道出什么问题了吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-01-22 20:31:45

MsHtmlBrowser只是用来查找元素并读取它们的属性值。它不支持点击链接、输入文本、触发事件、没有会话状态或任何其他与普通浏览器交互的方式。所以我们只对它进行报废。

HTH,Jeroen

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2110298

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档