org.jsoup.nodes.Comment#org.jsoup.nodes.FormElement源码实例Demo

下面列出了org.jsoup.nodes.Comment#org.jsoup.nodes.FormElement 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: astor   文件: UrlConnectTest.java
/**
 * Test fetching a form, and submitting it with a file attached.
 */
@Test
public void postHtmlFile() throws IOException {
    Document index = Jsoup.connect("http://direct.infohound.net/tidy/").get();
    FormElement form = index.select("[name=tidy]").forms().get(0);
    Connection post = form.submit();

    File uploadFile = ParseTest.getFile("/htmltests/google-ipod.html");
    FileInputStream stream = new FileInputStream(uploadFile);
    
    Connection.KeyVal fileData = post.data("_file");
    fileData.value("check.html");
    fileData.inputStream(stream);

    Connection.Response res;
    try {
        res = post.execute();
    } finally {
        stream.close();
    }

    Document out = res.parse();
    assertTrue(out.text().contains("HTML Tidy Complete"));
}
 
源代码2 项目: astor   文件: UrlConnectTest.java
/**
 * Test fetching a form, and submitting it with a file attached.
 */
@Test
public void postHtmlFile() throws IOException {
    Document index = Jsoup.connect("http://direct.infohound.net/tidy/").get();
    FormElement form = index.select("[name=tidy]").forms().get(0);
    Connection post = form.submit();

    File uploadFile = ParseTest.getFile("/htmltests/google-ipod.html");
    FileInputStream stream = new FileInputStream(uploadFile);
    
    Connection.KeyVal fileData = post.data("_file");
    fileData.value("check.html");
    fileData.inputStream(stream);

    Connection.Response res;
    try {
        res = post.execute();
    } finally {
        stream.close();
    }

    Document out = res.parse();
    assertTrue(out.text().contains("HTML Tidy Complete"));
}
 
源代码3 项目: astor   文件: UrlConnectTest.java
/**
 * Test fetching a form, and submitting it with a file attached.
 */
@Test
public void postHtmlFile() throws IOException {
    Document index = Jsoup.connect("http://direct.infohound.net/tidy/").get();
    FormElement form = index.select("[name=tidy]").forms().get(0);
    Connection post = form.submit();

    File uploadFile = ParseTest.getFile("/htmltests/google-ipod.html");
    FileInputStream stream = new FileInputStream(uploadFile);
    
    Connection.KeyVal fileData = post.data("_file");
    fileData.value("check.html");
    fileData.inputStream(stream);

    Connection.Response res;
    try {
        res = post.execute();
    } finally {
        stream.close();
    }

    Document out = res.parse();
    assertTrue(out.text().contains("HTML Tidy Complete"));
}
 
源代码4 项目: astor   文件: HtmlTreeBuilder.java
FormElement insertForm(Token.StartTag startTag, boolean onStack) {
    Tag tag = Tag.valueOf(startTag.name(), settings);
    FormElement el = new FormElement(tag, baseUri, startTag.attributes);
    setFormElement(el);
    insertNode(el);
    if (onStack)
        stack.add(el);
    return el;
}
 
源代码5 项目: astor   文件: HtmlParserTest.java
@Test public void createsFormElements() {
    String html = "<body><form><input id=1><input id=2></form></body>";
    Document doc = Jsoup.parse(html);
    Element el = doc.select("form").first();

    assertTrue("Is form element", el instanceof FormElement);
    FormElement form = (FormElement) el;
    Elements controls = form.elements();
    assertEquals(2, controls.size());
    assertEquals("1", controls.get(0).id());
    assertEquals("2", controls.get(1).id());
}
 
源代码6 项目: astor   文件: HtmlParserTest.java
@Test public void associatedFormControlsWithDisjointForms() {
    // form gets closed, isn't parent of controls
    String html = "<table><tr><form><input type=hidden id=1><td><input type=text id=2></td><tr></table>";
    Document doc = Jsoup.parse(html);
    Element el = doc.select("form").first();

    assertTrue("Is form element", el instanceof FormElement);
    FormElement form = (FormElement) el;
    Elements controls = form.elements();
    assertEquals(2, controls.size());
    assertEquals("1", controls.get(0).id());
    assertEquals("2", controls.get(1).id());

    assertEquals("<table><tbody><tr><form></form><input type=\"hidden\" id=\"1\"><td><input type=\"text\" id=\"2\"></td></tr><tr></tr></tbody></table>", TextUtil.stripNewlines(doc.body().html()));
}
 
源代码7 项目: astor   文件: HtmlTreeBuilder.java
FormElement insertForm(Token.StartTag startTag, boolean onStack) {
    Tag tag = Tag.valueOf(startTag.name(), settings);
    FormElement el = new FormElement(tag, baseUri, startTag.attributes);
    setFormElement(el);
    insertNode(el);
    if (onStack)
        stack.add(el);
    return el;
}
 
源代码8 项目: astor   文件: HtmlParserTest.java
@Test public void createsFormElements() {
    String html = "<body><form><input id=1><input id=2></form></body>";
    Document doc = Jsoup.parse(html);
    Element el = doc.select("form").first();

    assertTrue("Is form element", el instanceof FormElement);
    FormElement form = (FormElement) el;
    Elements controls = form.elements();
    assertEquals(2, controls.size());
    assertEquals("1", controls.get(0).id());
    assertEquals("2", controls.get(1).id());
}
 
源代码9 项目: astor   文件: HtmlParserTest.java
@Test public void associatedFormControlsWithDisjointForms() {
    // form gets closed, isn't parent of controls
    String html = "<table><tr><form><input type=hidden id=1><td><input type=text id=2></td><tr></table>";
    Document doc = Jsoup.parse(html);
    Element el = doc.select("form").first();

    assertTrue("Is form element", el instanceof FormElement);
    FormElement form = (FormElement) el;
    Elements controls = form.elements();
    assertEquals(2, controls.size());
    assertEquals("1", controls.get(0).id());
    assertEquals("2", controls.get(1).id());

    assertEquals("<table><tbody><tr><form></form><input type=\"hidden\" id=\"1\"><td><input type=\"text\" id=\"2\"></td></tr><tr></tr></tbody></table>", TextUtil.stripNewlines(doc.body().html()));
}
 
源代码10 项目: astor   文件: HtmlTreeBuilder.java
FormElement getFormElement() {
    return formElement;
}
 
源代码11 项目: astor   文件: HtmlTreeBuilder.java
void setFormElement(FormElement formElement) {
    this.formElement = formElement;
}
 
源代码12 项目: astor   文件: HtmlTreeBuilder.java
FormElement getFormElement() {
    return formElement;
}
 
源代码13 项目: astor   文件: HtmlTreeBuilder.java
void setFormElement(FormElement formElement) {
    this.formElement = formElement;
}