日期:2014-05-18  浏览次数:20855 次

自动填单的问题
在WinForm中,有一个WebBrower控件和Button按钮,在按钮的Click事件中处理如下:
webBrower.Navigate("URL");
if(webBrower.Document != null)
{
  HtmlElement txtUser = webBrowser.Document.All.GetElementsByName("user")[0];
  HtmlElement txtPw = webBrowser.Document.All.GetElementsByName("password")[0];
  if(txtUser != null && txtPw != null)
  {
  txtUser.SetAttribute("value", "......");
  txtPw.SetAttribute("value", "......");
  }
}
经调试,获得的txtUser和txtPw都是非空,但执行过后,页面中的两个文本框中并没有被填充上数据,这是为什么?

------解决方案--------------------
webBrower.Navigate("URL");
"URL"是什么地址?

难道网页中有同名的元素?