So I've figured out how to get an element by id, but I don't know how I can get an element by name.
private void SendData()
{
webBrowser1.Document.GetElementById("textfield1")
.SetAttribute("value", textBox1.Text);
webBrowser1.Document.GetElementById("textfield2")
.SetAttribute("value", textBox1.Text);
}
The problem is in HTML textfield1
is an id but textfield2
is a name. So I want to figure out how to get textfield2
:
<html>
<input type="text" id="textfield1" value="TEXT1"><br>
<input type="text" name="textfield2" value="TEXT2"><br>
<input type="submit" value="Submit">
</html>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…