I\'m trying to automate in a WinForm using a WebBrowser control to navigate and pull report info from a website. You can enter values in textboxes and invoke the click events fo
I'm answering on this post after five years, for the people who are searching a solution of this problem.
If you just need to submit/post a value for the dropdown then this line is sufficient:
webBrowser1.Document.GetElementById("term_id").SetAttribute("value", "200980");
But if you really need to select an underlying OPTION, then:
HtmlElement selectDom = webBrowser1.Document.GetElementById("term_id");
foreach (HtmlElement option in selectDom.GetElementsByTagName("option"))
{
if (option.GetAttribute("value") == "200980")
{
var dom = option.DomElement as dynamic;
dom.selected = true;
// selectDom.InvokeMember("onChange"); // if you need this too
break;
}
}