Package org.htmlparser.scanners

Examples of org.htmlparser.scanners.FormScanner


    public void testSearchFor() throws ParserException
    {
        createParser(FormScannerTest.FORM_HTML);

        parser.addScanner(new FormScanner(parser));
        parseAndAssertNodeCount(1);
        assertTrue("Node 0 should be Form Tag", node[0] instanceof FormTag);
        FormTag formTag = (FormTag) node[0];
        NodeList nodeList = formTag.searchFor("USER NAME");
        assertEquals("Should have found nodes", 1, nodeList.size());
View Full Code Here


    public void testSearchByName() throws ParserException
    {
        createParser(FormScannerTest.FORM_HTML);

        parser.addScanner(new FormScanner(parser));
        parseAndAssertNodeCount(1);
        assertTrue("Node 0 should be Form Tag", node[0] instanceof FormTag);
        FormTag formTag = (FormTag) node[0];

        Tag tag = formTag.searchByName("passwd");
View Full Code Here

    public void testRemoveScanner() throws Exception
    {
        createParser("");
        parser.registerScanners();
        parser.removeScanner(new FormScanner("", parser));
        Map scanners = parser.getScanners();
        TagScanner scanner = (TagScanner) scanners.get("FORM");
        assertNull("shouldnt have found scanner", scanner);
    }
View Full Code Here

            "form method=\"post\" onsubmit=\"return implementsearch()\" name=frmsearch id=form";
        String line2 =
            "FORM method=\"post\" onsubmit=\"return implementsearch()\" name=frmsearch id=form";
        String line3 =
            "Form method=\"post\" onsubmit=\"return implementsearch()\" name=frmsearch id=form";
        FormScanner formScanner = new FormScanner("", Parser.createParser(""));
        assertTrue("Line 1", formScanner.evaluate(line1, null));
        assertTrue("Line 2", formScanner.evaluate(line2, null));
        assertTrue("Line 3", formScanner.evaluate(line3, null));
    }
View Full Code Here

            inputTag.getAttribute("VALUE"));
    }
    public void testScan() throws ParserException
    {
        createParser(FORM_HTML, "http://www.google.com/test/index.html");
        parser.addScanner(new FormScanner("", parser));
        parseAndAssertNodeCount(1);
        assertTrue("Node 0 should be Form Tag", node[0] instanceof FormTag);
        FormTag formTag = (FormTag) node[0];
        assertStringEquals("Method", FormTag.POST, formTag.getFormMethod());
        assertStringEquals(
View Full Code Here

                + "<TR><TD ALIGN=\"center\">&nbsp;</TD></TR>\n"
                + "<INPUT TYPE=\"hidden\" NAME=\"password\" SIZE=\"20\">\n"
                + "</TABLE>",
            "http://www.google.com/test/index.html");

        parser.addScanner(new FormScanner("", parser));

        parseAndAssertNodeCount(2);
    }
View Full Code Here

                + "submit value=\"I'm Feeling Lucky\" name=btnI></td><td valign=top nowrap><font size=-2>"
                + "&nbsp;&#8226;&nbsp;<a href=/advanced_search?hl=en>Advanced&nbsp;Search</a><br>&nbsp;&#8226;"
                + "&nbsp;<a href=/preferences?hl=en>Preferences</a><br>&nbsp;&#8226;&nbsp;<a href=/"
                + "language_tools?hl=en>Language Tools</a></font></td></tr></table></form>");

        parser.addScanner(new FormScanner("", parser));
        parser.addScanner(new LinkScanner());
        parseAndAssertNodeCount(1);
        assertTrue("Should be a HTMLFormTag", node[0] instanceof FormTag);
        FormTag formTag = (FormTag) node[0];
        LinkTag[] linkTag = new LinkTag[10];
View Full Code Here

                + "submit value=\"I'm Feeling Lucky\" name=btnI></td><td valign=top nowrap><font size=-2>"
                + "&nbsp;&#8226;&nbsp;<a href=/advanced_search?hl=en>Advanced&nbsp;Search</a><br>&nbsp;&#8226;"
                + "&nbsp;<a href=/preferences?hl=en>Preferences</a><br>&nbsp;&#8226;&nbsp;<a href=/"
                + "language_tools?hl=en>Language Tools</a></font></td></tr></table></form>");

        parser.addScanner(new FormScanner("", parser));
        parseAndAssertNodeCount(1);
        assertTrue("Should be a HTMLFormTag", node[0] instanceof FormTag);
        FormTag formTag = (FormTag) node[0];
        RemarkNode[] remarkNode = new RemarkNode[10];
        int i = 0;
View Full Code Here

                + "<A HREF=\"http://www.helpme.com\">Help</A> "
                + "<INPUT TYPE=\"checkbox\">\n"
                + "<P>\n"
                + "<INPUT TYPE=\"SUBMIT\">\n"
                + "</FORM>");
        parser.addScanner(new FormScanner("", parser));
        parser.addScanner(new LinkScanner());
        parseAndAssertNodeCount(6);
        assertTrue("Fifth Node is a link", node[4] instanceof LinkTag);
        LinkTag linkTag = (LinkTag) node[4];
        assertEquals("Link Text", "Yahoo!\r\n", linkTag.getLinkText());
View Full Code Here

            "<HTML><HEAD><TITLE>Test Form Tag</TITLE></HEAD>"
                + "<BODY><FORM name=\"form0\"><INPUT type=\"text\" name=\"text0\"></FORM>"
                + "</BODY></HTML>";
        createParser(testHTML);
        parser.registerScanners();
        parser.removeScanner(new FormScanner("", parser));
        Node[] nodes = parser.extractAllNodesThatAre(FormTag.class);
        assertEquals("shouldnt have found form tag", 0, nodes.length);
    }
View Full Code Here

TOP

Related Classes of org.htmlparser.scanners.FormScanner

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.