I am working on a simple application that automatically views a page containing two drop-down menus and a button. The page is as follows:
------ DropDown1 -------
------ DropDown2 -------
------- Button ---------
Now the problem is that the content is DropDown2dynamically generated by the selection Dropdown1.
I wrote code like this in C #:
private void webBrowser1_DocumentCompleted(object sender,
WebBrowserDocumentCompletedEventArgs e)
{
HtmlElement elem = webBrowser1.Document.GetElementById("DropDown1");
elem.SetAttribute("selectedIndex", "1");
elem.RaiseEvent("onChange");
HtmlElement elem = webBrowser1.Document.GetElementById("DropDown2");
elem.SetAttribute("selectedIndex", "5");
elem.RaiseEvent("onChange");
}
After raising the event, the onChangebrowser loads the new values, but I cannot get and set the value DropDown2, because the document still believes that the values DropDown2are empty.
How can I get and set new values generated in DropDown2?