public static FormValue FromSelect(ElementWrapper select, FormValue formValue) { var options = select.FindAll("option"); var texts = new List <string>(); var values = new List <string>(); foreach (var option in options) { var text = option.TextContent; var value = option.HasAttribute("value") ? option.Attribute("value") : text; texts.Add(text); values.Add(value); if (option.HasAttribute("selected")) { formValue.SetValue(value); } } formValue.SetConfinedValues(values, texts); return(formValue); }
protected virtual void AddInputs <T>(TypedForm <T> form) { var formInputs = _element.FindAll("input, select, textarea, button"); var submits = formInputs.Where(i => IsSubmit(i)); var inputs = formInputs.Where(i => !IsSubmit(i)); foreach (var submit in submits) { AddSubmit(form, submit); } var formValues = FormValueScraper.FromElements(inputs); foreach (var formValue in formValues) { form.AddFormValue(formValue); } }