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.

Re: Pick value in dropdown combo on WebBrowser page by angelo

angelo
Thu Jul 31 09:01:13 CDT 2008

On 5 Giu, 05:51, BobRoyAce <b...@omegasoftwareinc.com> wrote:
> 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:
>
> =A0 Dim oHtmlElement As HtmlElement
> =A0 oHtmlElement =3D WebBrowser1.Document.GetElementById("cboGroups")
> =A0 oHtmlElement.InnerText =3D "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 =3D webBrowser1.Document.All["cboGroups"];
el.Children[i].SetAttribute("selected", "x");

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

Angelo