Webbrowser control:
Dim element As HtmlElement =
WebBrowser1.Document.GetElementsByTagName("select").Cast(Of HtmlElement).First(Function(el) el.GetAttribute("name") = "package_id")
element.GetElementsByTagName("option").Cast(Of HtmlElement).First(Function(el) el.InnerText = "UNL").SetAttribute("selected", "selected")
How to do this in Awesomium?
Tried this:
WebControl1.ExecuteJavascript("$('#country').value('NL');")
WebControl1.ExecuteJavascript("document.getElementById('country').selectedIndex = NL")
Doesn't work. Can anyone give me a little help here?
Your last one looks like it should work, except you can't set a text value to selected index...it only takes integers, so you'd need to know NL's index to select it that way. If you don't know the index, you will have to either loop through the select options and find it, or try using queryselector. If you know the value of the select option, use this:
WebControl1.ExecuteJavascript("document.querySelector('option[value='NL']').selected = true;")
Note that the code above is searching the values, not the text...and also the 'NL' part must be an exact match to what's in the select, including single vs. double quotes. For example:
<option value="CA">California</option> would need queryselector('option[value="CA"]'])
and
<option value='CA'>California</option> would need queryselector('option[value='CA']'])