public void Submit() { var document = _form.Submit().Result; Console.WriteLine(document.ToHtml()); Console.ReadLine(); }
/// <summary> /// Submits the given form by using the dictionary which contains name /// value pairs of input fields to submit. /// </summary> /// <param name="form">The form to submit.</param> /// <param name="fields">The fields to use as values.</param> /// <returns>The task eventually resulting in the response.</returns> public static Task <IDocument> Submit(this IHtmlFormElement form, IDictionary <String, String> fields) { if (form == null) { throw new ArgumentNullException("form"); } if (fields == null) { throw new ArgumentNullException("fields"); } var elements = form.Elements; foreach (var element in elements.OfType <IHtmlInputElement>()) { var value = default(String); if (fields.TryGetValue(element.Name ?? String.Empty, out value)) { element.Value = value; } } return(form.Submit()); }
/// <summary> /// Submits the given form by using the dictionary which contains name /// value pairs of input fields to submit. /// </summary> /// <param name="form">The form to submit.</param> /// <param name="fields">The fields to use as values.</param> /// <param name="createInputIfNoFound">What to do if some field/s have not found in the form. If true, then new input will be created. /// If false, KeyNotFoundException will be thrown. /// The default is false. /// </param> /// <returns>The task eventually resulting in the response.</returns> public static Task <IDocument> Submit(this IHtmlFormElement form, IDictionary <String, String> fields, bool createInputIfNoFound = false) { if (form == null) { throw new ArgumentNullException("form"); } if (fields == null) { throw new ArgumentNullException("fields"); } form.SetFieldsValues(fields, createInputIfNoFound); return(form.Submit()); }
/// <summary> /// Submits the given form by using the dictionary which contains name /// value pairs of input fields to submit. /// </summary> /// <param name="form">The form to submit.</param> /// <param name="fields">The fields to use as values.</param> /// <param name="createInputIfNotFound"> /// What to do if some field(s) have not been found in the form. If /// true, then new input will be created. Otherwise, an exception will /// be thrown. /// </param> /// <returns>The task eventually resulting in the response.</returns> public static Task <IDocument> Submit(this IHtmlFormElement form, IDictionary <String, String> fields, Boolean createInputIfNotFound = false) { form.SetFieldValues(fields, createInputIfNotFound); return(form.Submit()); }
/// <summary> /// Submits the given form by decomposing the object into a dictionary /// that contains its properties as name value pairs. /// </summary> /// <param name="form">The form to submit.</param> /// <param name="fields">The fields to use as values.</param> /// <returns>The task eventually resulting in the response.</returns> public static Task <IDocument> Submit(this IHtmlFormElement form, Object fields) { return(form.Submit(fields.ToDictionary())); }