public virtual void UsesOnForCheckboxValueIfNoValueSet() { Document doc = iText.StyledXmlParser.Jsoup.Jsoup.Parse("<form><input type=checkbox checked name=foo></form>" ); FormElement form = (FormElement)doc.Select("form").First(); IList <KeyVal> data = form.FormData(); NUnit.Framework.Assert.AreEqual("on", data[0].Value()); NUnit.Framework.Assert.AreEqual("foo", data[0].Key()); }
public virtual void ControlsAddedAfterParseAreLinkedWithForms() { Document doc = iText.StyledXmlParser.Jsoup.Jsoup.Parse("<body />"); doc.Body().Html("<form />"); iText.StyledXmlParser.Jsoup.Nodes.Element formEl = doc.Select("form").First(); formEl.Append("<input name=foo value=bar>"); NUnit.Framework.Assert.IsTrue(formEl is FormElement); FormElement form = (FormElement)formEl; NUnit.Framework.Assert.AreEqual(1, form.Elements().Count); IList <KeyVal> data = form.FormData(); NUnit.Framework.Assert.AreEqual("foo=bar", data[0].ToString()); }
public virtual void AdoptedFormsRetainInputs() { // test for https://github.com/jhy/jsoup/issues/249 String html = "<html>\n" + "<body> \n" + " <table>\n" + " <form action=\"/hello.php\" method=\"post\">\n" + " <tr><td>User:</td><td> <input type=\"text\" name=\"user\" /></td></tr>\n" + " <tr><td>Password:</td><td> <input type=\"password\" name=\"pass\" /></td></tr>\n" + " <tr><td><input type=\"submit\" name=\"login\" value=\"login\" /></td></tr>\n" + " </form>\n" + " </table>\n" + "</body>\n" + "</html>"; Document doc = iText.StyledXmlParser.Jsoup.Jsoup.Parse(html); FormElement form = (FormElement)doc.Select("form").First(); IList <KeyVal> data = form.FormData(); NUnit.Framework.Assert.AreEqual(3, data.Count); NUnit.Framework.Assert.AreEqual("user", data[0].Key()); NUnit.Framework.Assert.AreEqual("pass", data[1].Key()); NUnit.Framework.Assert.AreEqual("login", data[2].Key()); }
public virtual void CreatesFormData() { String html = "<form><input name='one' value='two'><select name='three'><option value='not'>" + "<option value='four' selected><option value='five' selected><textarea name=six>seven</textarea>" + "<input name='seven' type='radio' value='on' checked><input name='seven' type='radio' value='off'>" + "<input name='eight' type='checkbox' checked><input name='nine' type='checkbox' value='unset'>" + "<input name='ten' value='text' disabled>" + "</form>"; Document doc = iText.StyledXmlParser.Jsoup.Jsoup.Parse(html); FormElement form = (FormElement)doc.Select("form").First(); IList <KeyVal> data = form.FormData(); NUnit.Framework.Assert.AreEqual(6, data.Count); NUnit.Framework.Assert.AreEqual("one=two", data[0].ToString()); NUnit.Framework.Assert.AreEqual("three=four", data[1].ToString()); NUnit.Framework.Assert.AreEqual("three=five", data[2].ToString()); NUnit.Framework.Assert.AreEqual("six=seven", data[3].ToString()); NUnit.Framework.Assert.AreEqual("seven=on", data[4].ToString()); // set NUnit.Framework.Assert.AreEqual("eight=on", data[5].ToString()); }