int all = webBrowser1.Document.Body.All.Count; for (int i = 0; i < all; i++) { HtmlElement GetElement = webBrowser1.Document.All[i]; //取到包含input标签的元素 //_fmm.com._0.c if (GetElement.TagName.ToUpper().ToString() == "INPUT") { //根据input的Name属性,找到该元素并赋值:给用户名输入框赋值 if (GetElement.Name.ToString() == "_fmm.com._0.c") { webBrowser1.Document.All[i].SetAttribute("value", "jcgh201098121"); } } }