【发布时间】:2013-12-01 03:37:21
【问题描述】:
我正在开发包含 Web 浏览器控件的 win 表单应用程序,在网页中有 一个文本框字段,我将其作为 htmlelement..
我用一个字符串值正确填充它,然后我想发送回车键来提交 里面的价值..
这是我目前的代码:
HtmlDocument hd = wbr.Document;//wbr is web browser control
HtmlElement he = hd.GetElementById("response_field");
he.SetAttribute("value", ans);//filled correctly
wbr.Select();
he.Focus();
he.InvokeMember("submit");
SendKeys.Send("{ENTER}");
我尝试过调用成员,尝试过 sendkey,但它们都不起作用..
如何做到这一点?
【问题讨论】:
-
您需要在
<form>元素上使用InvokeMember("submit"),而不是在其子元素之一上。看看这个:stackoverflow.com/q/1539685/1768303
标签: c# webbrowser-control