Pick value in dropdown combo on WebBrowser page

  • Thread starter Thread starter BobRoyAce
  • Start date Start date
B

BobRoyAce

I have a WebBrowser on a form and I am automating some data entry on
pages displayed therein. I know how to select/click on a radio button
or checkbox. I know how to set the value of a text box. But, how do I
programmatically set the value picked in a drop down? I tried the
following:

Dim oHtmlElement As HtmlElement
oHtmlElement = WebBrowser1.Document.GetElementById("cboGroups")
oHtmlElement.InnerText = "Group 1"

but that doesn't work, even though "Group 1" is one of the options in
the dropdown.
 
I have a WebBrowser on a form and I am automating some data entry on
pages displayed therein. I know how to select/click on a radio button
or checkbox. I know how to set the value of a text box. But, how do I
programmatically set the value picked in a drop down? I tried the
following:

  Dim oHtmlElement As HtmlElement
  oHtmlElement = WebBrowser1.Document.GetElementById("cboGroups")
  oHtmlElement.InnerText = "Group 1"

but that doesn't work, even though "Group 1" is one of the options in
the dropdown.

try with this (sorry only in C#, you have to translate it):

HtmlElement el = webBrowser1.Document.All["cboGroups"];
el.Children.SetAttribute("selected", "x");

where i is the index of the item you want to select

Angelo
 
Back
Top