如果你告诉我为什么它不起作用会很感激。当我按下按钮时没有任何反应。
// <input type="text" name="nick" value="" size="25" tabindex="1" maxlength="50" class="material-input" required="">
private void loginName()
{
HtmlElementCollection classButton = webBrowser1.Document.All;
foreach (HtmlElement element in classButton)
{
if (element.GetAttribute("material-input") == "input")
{
element.SetAttribute("name", "abcdfefefefe");
}
}
}
private void button1_Click(object sender, EventArgs e)
{
loginName();
}
编辑: 这是一个很好的解决方案吗?
var loginElement = webBrowser1.Document.GetElementsByTagName("input")["nick"];
passwordElement.SetAttribute("value", "abcdfefefefe");