mohammed qadoora mohammed qadoora - 1 month ago 8
C# Question

select combobox item in website using c#

I need to select a combo box item in a website using c#

i open a website using a web browser

my code is

webBrowser1.Navigate("xxxxx.com");
HtmlElementCollection Col2;
Col2 = webBrowser1.Document.GetElementsByTagName("select");
foreach (HtmlElement ele in Col2)
{
if (ele.Id == "country")
{
ele.InnerText=("palestine");
}
}


where is Palestine is one of the items in the combo box.
any help please

Answer
webBrowser1.Document.GetElementsByTagName("select").SetAttribute("value", "palestine");