日期:2014-05-18 浏览次数:21014 次
private void btnSearch_Click(object sender, EventArgs e) { try { wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted); wb.Navigate("www.cqjg.gov.cn/DriverFind.html"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { #region 参数设置 HtmlElement btnSubmit = wb.Document.All["formthree"]; //获取登录对应元素 HtmlElement tbUserid = wb.Document.All["txtDname"]; //获取用户名对应元素 HtmlElement tbStyle = wb.Document.All["txtCertificate"]; //获取证件号对应元素 tbUserid.SetAttribute("value", "宋世"); //给用户名赋值 tbStyle.SetAttribute("value", "1234567"); //给密码赋值 btnSubmit.InvokeMember("submit"); //模拟点击登录按钮 #endregion }
private void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { if (webBrowser1.ReadyState == WebBrowserReadyState.Complete) { #region 参数设置 HtmlElement btnSubmit = wb.Document.All["formthree"]; //获取登录对应元素 HtmlElement tbUserid = wb.Document.All["txtDname"]; //获取用户名对应元素 HtmlElement tbStyle = wb.Document.All["txtCertificate"]; //获取证件号对应元素 tbUserid.SetAttribute("value", "宋世"); //给用户名赋值 tbStyle.SetAttribute("value", "1234567"); //给密码赋值 btnSubmit.InvokeMember("submit"); //模拟点击登录按钮 #endregion } }