Package com.gargoylesoftware.htmlunit.html

Examples of com.gargoylesoftware.htmlunit.html.HtmlDivision


        HtmlPage page = htmlPage( file );
        assertNotNull( page );

        HtmlElement element = page.getHtmlElementById( "contentBox" );
        assertNotNull( element );
        HtmlDivision division = (HtmlDivision) element;
        assertNotNull( division );

        Iterator<HtmlElement> elementIterator = division.getHtmlElementDescendants().iterator();

        // ----------------------------------------------------------------------
        //
        // ----------------------------------------------------------------------
View Full Code Here


        HtmlPage page = htmlPage( file );
        assertNotNull( page );

        HtmlElement element = page.getHtmlElementById( "contentBox" );
        assertNotNull( element );
        HtmlDivision division = (HtmlDivision) element;
        assertNotNull( division );

        Iterator<HtmlElement> elementIterator = division.getHtmlElementDescendants().iterator();

        // ----------------------------------------------------------------------
        //
        // ----------------------------------------------------------------------

        HtmlDivision div = (HtmlDivision) elementIterator.next();
        assertEquals( "section", div.getAttribute( "class" ) );

        HtmlHeading2 h2 = (HtmlHeading2) elementIterator.next();
        assertNotNull( h2 );
        assertEquals( "section", h2.asText().trim() );

        HtmlAnchor a = (HtmlAnchor) elementIterator.next();
        assertNotNull( a );
        assertEquals( "section", a.getAttribute( "name" ) );

        HtmlParagraph p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );

        assertEquals( "ID",  p.getAttribute( "id" ) );
        assertEquals( "CLASS", p.getAttribute( "class" ) );
        assertEquals( "TITLE", p.getAttribute( "title" ) );
        assertEquals( "STYLE", p.getAttribute( "style" ) );
        assertEquals( "LANG", p.getAttribute( "lang" ) );

        HtmlImage img = (HtmlImage) elementIterator.next();
        assertNotNull( img );

        assertEquals( "project.png", img.getAttribute( "src" ) );
        assertEquals( "150", img.getAttribute( "width" ) );
        assertEquals( "93", img.getAttribute( "height" ) );
        assertEquals( "border: 1px solid silver", img.getAttribute( "style" ) );
        assertEquals( "Project", img.getAttribute( "alt" ) );

        // test object identity to distinguish the case ATTRIBUTE_VALUE_EMPTY
        assertTrue( img.getAttribute( "dummy" ) == HtmlElement.ATTRIBUTE_NOT_DEFINED );

        HtmlTable table = (HtmlTable) elementIterator.next();
        assertEquals( "1", table.getAttribute( "border" ) );
        assertEquals( "none", table.getAttribute( "class" ) );

        element = elementIterator.next();
        // this is a htmlunit bug
        assertEquals( "tbody", element.getTagName() );

        HtmlTableRow tr = (HtmlTableRow) elementIterator.next();
        HtmlTableHeaderCell th = (HtmlTableHeaderCell) elementIterator.next();

        th = (HtmlTableHeaderCell) elementIterator.next();
        assertEquals( "center", th.getAttribute( "align" ) );
        assertEquals( "2", th.getAttribute( "colspan" ) );
        assertEquals( "50%", th.getAttribute( "width" ) );

        tr = (HtmlTableRow) elementIterator.next();

        th = (HtmlTableHeaderCell) elementIterator.next();
        assertEquals( "2", th.getAttribute( "rowspan" ) );
        assertEquals( "middle", th.getAttribute( "valign" ) );

        HtmlTableDataCell td = (HtmlTableDataCell) elementIterator.next();
        td = (HtmlTableDataCell) elementIterator.next();
        tr = (HtmlTableRow) elementIterator.next();
        td = (HtmlTableDataCell) elementIterator.next();
        td = (HtmlTableDataCell) elementIterator.next();

        p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );

        HtmlUnderlined u = (HtmlUnderlined) elementIterator.next();
        assertEquals( "u", u.getTagName() );
        HtmlS s = (HtmlS) elementIterator.next();
        assertEquals( "s", s.getTagName() );
        HtmlSubscript sub = (HtmlSubscript) elementIterator.next();
        assertEquals( "sub", sub.getTagName() );
        HtmlSuperscript sup = (HtmlSuperscript) elementIterator.next();
        assertEquals( "sup", sup.getTagName() );

        p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );

        HtmlBold b = (HtmlBold) elementIterator.next();
        assertEquals( "b", b.getTagName() );
        HtmlItalic i = (HtmlItalic) elementIterator.next();
        assertEquals( "i", i.getTagName() );
        i = (HtmlItalic) elementIterator.next();
        assertEquals( "i", i.getTagName() );
        b = (HtmlBold) elementIterator.next();
        assertEquals( "b", b.getTagName() );

        p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );
        assertEquals( "color: red; margin-left: 20px", p.getAttribute( "style" ) );

        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "Anchor", a.getAttribute( "name" ) );

        p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );

        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "#Anchor", a.getAttribute( "href" ) );
        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "#Anchor", a.getAttribute( "href" ) );
        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "http://maven.apache.org/", a.getAttribute( "href" ) );
        assertEquals( "externalLink", a.getAttribute( "class" ) );
        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "./cdc.html", a.getAttribute( "href" ) );
        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "cdc.html", a.getAttribute( "href" ) );
        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "cdc.pdf", a.getAttribute( "href" ) );
        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "./cdc.txt", a.getAttribute( "href" ) );
        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "/index.html", a.getAttribute( "href" ) );

        div = (HtmlDivision) elementIterator.next();
        assertEquals( "source", div.getAttribute( "class" ) );
        HtmlPreformattedText pre = (HtmlPreformattedText) elementIterator.next();
        assertEquals( "pretty", pre.getAttribute( "class" ) );

        div = (HtmlDivision) elementIterator.next();
        assertEquals( "source", div.getAttribute( "class" ) );
        assertEquals( "", div.getAttribute( "id" ) );
        pre = (HtmlPreformattedText) elementIterator.next();
        assertEquals( "pretty", pre.getAttribute( "id" ) );

        div = (HtmlDivision) elementIterator.next();
        assertEquals( "section", div.getAttribute( "class" ) );
        h2 = (HtmlHeading2) elementIterator.next();
        assertEquals( "Section without id", h2.asText().trim() );
        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "Section_without_id", a.getAttribute( "name" ) );

        div = (HtmlDivision) elementIterator.next();
        assertEquals( "section", div.getAttribute( "class" ) );
        HtmlHeading3 h3 = (HtmlHeading3) elementIterator.next();
        assertEquals( "Subsection without id", h3.asText().trim() );
        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "Subsection_without_id", a.getAttribute( "name" ) );

        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "section-id", a.getAttribute( "name" ) );
        div = (HtmlDivision) elementIterator.next();
        assertEquals( "section", div.getAttribute( "class" ) );
        h2 = (HtmlHeading2) elementIterator.next();
        assertEquals( "Section with id", h2.asText().trim() );
        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "Section_with_id", a.getAttribute( "name" ) );

        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "subsection-id", a.getAttribute( "name" ) );
        div = (HtmlDivision) elementIterator.next();
        assertEquals( "section", div.getAttribute( "class" ) );
        h3 = (HtmlHeading3) elementIterator.next();
        assertEquals( "Subsection with id", h3.asText().trim() );
        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "Subsection_with_id", a.getAttribute( "name" ) );

        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "foo", a.getAttribute( "name" ) );
        div = (HtmlDivision) elementIterator.next();
        assertEquals( "bar", div.getAttribute( "class" ) );
        assertEquals( "foo", div.getAttribute( "id" ) );
        h2 = (HtmlHeading2) elementIterator.next();
        assertEquals( "Section name", h2.asText().trim() );
        assertEquals( "", h2.getAttribute( "class" ) );
        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "Section_name", a.getAttribute( "name" ) );

        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "subfoo", a.getAttribute( "name" ) );
        div = (HtmlDivision) elementIterator.next();
        assertEquals( "subbar", div.getAttribute( "class" ) );
        assertEquals( "subfoo", div.getAttribute( "id" ) );
        h3 = (HtmlHeading3) elementIterator.next();
        assertEquals( "Subsection name", h3.asText().trim() );
        assertEquals( "", h3.getAttribute( "class" ) );
        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "Subsection_name", a.getAttribute( "name" ) );
View Full Code Here

        assertTrue( author.toString().indexOf( "test&#169;email.com" ) > 0 );
        assertEquals( "test\u00A9email.com", author.getContentAttribute() );

        HtmlElement element = page.getHtmlElementById( "contentBox" );
        assertNotNull( element );
        HtmlDivision division = (HtmlDivision) element;
        assertNotNull( division );

        Iterator<HtmlElement> elementIterator = division.getHtmlElementDescendants().iterator();

        // ----------------------------------------------------------------------
        //
        // ----------------------------------------------------------------------

        HtmlDivision div = (HtmlDivision) elementIterator.next();
        assertNotNull( div );
        assertEquals( div.getAttribute( "class" ), "section" );

        HtmlHeading2 h2 = (HtmlHeading2) elementIterator.next();
        assertNotNull( h2 );
        assertEquals( h2.asText().trim(), "section name with entities: '&' '\u0391' ' ' '\uD7ED'" );

        HtmlAnchor a = (HtmlAnchor) elementIterator.next();
        assertNotNull( a );
        assertEquals( a.getAttribute( "name" ), "section_name_with_entities:____" );

        div = (HtmlDivision) elementIterator.next();
        assertNotNull( div );
        assertEquals( div.getAttribute( "class" ), "section" );

        div = (HtmlDivision) elementIterator.next();
        assertNotNull( div );
        assertEquals( div.getAttribute( "class" ), "section" );

        HtmlHeading4 h4 = (HtmlHeading4) elementIterator.next();
        assertNotNull( h4 );
        assertEquals( h4.asText().trim(), "Entities" );

        a = (HtmlAnchor) elementIterator.next();
        assertNotNull( a );
        assertEquals( a.getAttribute( "name" ), "Entities" );

        div = (HtmlDivision) elementIterator.next();

        HtmlHeading3 h3 = (HtmlHeading3) elementIterator.next();
        assertNotNull( h3 );
        assertEquals( h3.asText().trim(), "Generic Entities: '&' '<' '>' '\"' '''" );

        a = (HtmlAnchor) elementIterator.next();

        HtmlParagraph p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );
        assertEquals( p.asText().trim(), "'&' '<' '>' '\"' '''" );

        div = (HtmlDivision) elementIterator.next();

        h3 = (HtmlHeading3) elementIterator.next();
        assertNotNull( h3 );
        assertEquals( h3.asText().trim(), "Local Entities: '\u0391' '\u0392' '\u0393' '\uD7ED'" );

        a = (HtmlAnchor) elementIterator.next();

        p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );
        assertEquals( p.asText().trim(), "'\u0391' '\u0392' '\u0393' '\uD7ED\uD7ED' '\u0159\u0159' '\u0159'" );

        div = (HtmlDivision) elementIterator.next();

        h3 = (HtmlHeading3) elementIterator.next();
        assertNotNull( h3 );
        assertEquals( h3.asText().trim(), "DTD Entities: ' ' '\u00A1' '\u00A2'" );

        a = (HtmlAnchor) elementIterator.next();

        p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );
        assertEquals( p.asText().trim(), "' ' '\u00A1' '\u00A2'" );

        div = (HtmlDivision) elementIterator.next();
        assertNotNull( div );
        assertEquals( div.getAttribute( "class" ), "section" );

        h4 = (HtmlHeading4) elementIterator.next();
        assertNotNull( h4 );
        assertEquals( h4.asText().trim(), "CDATA" );

        a = (HtmlAnchor) elementIterator.next();
        assertNotNull( a );
        assertEquals( a.getAttribute( "name" ), "CDATA" );

        div = (HtmlDivision) elementIterator.next();
        assertNotNull( div );
        assertEquals( div.getAttribute( "class" ), "source" );

        HtmlPreformattedText pre = (HtmlPreformattedText) elementIterator.next();
        assertNotNull( pre );
        assertEquals( pre.asText().trim(), "<project xmlns:ant=\"jelly:ant\">" );
View Full Code Here

        HtmlPage page = htmlPage( file );
        assertNotNull( page );

        HtmlElement element = page.getHtmlElementById( "contentBox" );
        assertNotNull( element );
        HtmlDivision division = (HtmlDivision) element;
        assertNotNull( division );

        Iterator<HtmlElement> elementIterator = division.getHtmlElementDescendants().iterator();

        // ----------------------------------------------------------------------
        // Verify link
        // ----------------------------------------------------------------------

        HtmlDivision div = (HtmlDivision) elementIterator.next();
        assertNotNull( div );
        assertEquals( div.getAttribute( "class" ), "section" );

        HtmlHeading2 h2 = (HtmlHeading2) elementIterator.next();
        assertNotNull( h2 );
        assertEquals( h2.asText().trim(), "List Section" );

        HtmlAnchor a = (HtmlAnchor) elementIterator.next();
        assertNotNull( a );
        assertEquals( a.getAttribute( "name" ), "List_Section" );

        // ----------------------------------------------------------------------
        // Unordered lists
        // ----------------------------------------------------------------------
        div = (HtmlDivision) elementIterator.next();
        assertNotNull( div );
        assertEquals( div.getAttribute( "class" ), "section" );

        div = (HtmlDivision) elementIterator.next();
        assertNotNull( div );
        assertEquals( div.getAttribute( "class" ), "section" );

        HtmlHeading4 h4 = (HtmlHeading4) elementIterator.next();
        assertNotNull( h4 );
        assertEquals( h4.asText().trim(), "Unordered lists" );

        a = (HtmlAnchor) elementIterator.next();
        assertNotNull( a );
        assertEquals( a.getAttribute( "name" ), "Unordered_lists" );

        HtmlParagraph p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );
        assertEquals( p.asText().trim(), "Below is an unordered list, followed by six paragraphs." );

        HtmlUnorderedList ul = (HtmlUnorderedList) elementIterator.next();
        assertNotNull( ul );

        HtmlListItem li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        assertEquals( li.getFirstChild().asText().trim(), "Item 1." );

        ul = (HtmlUnorderedList) elementIterator.next();
        assertNotNull( ul );

        li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );
        assertEquals( p.getFirstChild().asText().trim(), "Item 11." );
        li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );
        assertEquals( p.getFirstChild().asText().trim(), "Item 12." );
        li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        assertEquals( li.getFirstChild().asText().trim(), "Item 13." );
        li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        assertEquals( li.getFirstChild().asText().trim(), "Item 14." );
        li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        assertEquals( li.getFirstChild().asText().trim(), "Item 2." );
        li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        assertEquals( li.getFirstChild().asText().trim(), "Item 3." );
        li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        assertEquals( li.getFirstChild().asText().trim(), "Item 4." );

        ul = (HtmlUnorderedList) elementIterator.next();
        assertNotNull( ul );

        li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        assertEquals( li.getFirstChild().asText().trim(), "Item 41." );
        li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        assertEquals( li.getFirstChild().asText().trim(), "Item 42." );
        li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        assertEquals( li.getFirstChild().asText().trim(), "Item 43." );
        li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        assertEquals( li.getFirstChild().asText().trim(), "Item 44." );

        p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );
        assertEquals( p.asText().trim(), "Paragraph 1 below list." );
        p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );
        assertEquals( p.asText().trim(), "Paragraph 2 below list." );
        p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );
        assertEquals( p.asText().trim(), "Paragraph 3 below list." );
        p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );
        assertEquals( p.asText().trim(), "Paragraph 4 below list." );
        p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );
        assertEquals( p.asText().trim(), "Paragraph 5 below list." );
        p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );
        assertEquals( p.asText().trim(), "Paragraph 6 below list." );

        // ----------------------------------------------------------------------
        // Ordered lists
        // ----------------------------------------------------------------------
        div = (HtmlDivision) elementIterator.next();
        assertNotNull( div );
        assertEquals( div.getAttribute( "class" ), "section" );

        h4 = (HtmlHeading4) elementIterator.next();
        assertNotNull( h4 );
        assertEquals( h4.asText().trim(), "Ordered lists" );

        a = (HtmlAnchor) elementIterator.next();
        assertNotNull( a );
        assertEquals( a.getAttribute( "name" ), "Ordered_lists" );

        p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );
        assertEquals( p.asText().trim(), "Below is an ordered list, followed by six paragraphs." );

        HtmlOrderedList ol = (HtmlOrderedList) elementIterator.next();
        assertNotNull( ol );

        li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        assertEquals( li.getFirstChild().asText().trim(), "Item 1." );

        ol = (HtmlOrderedList) elementIterator.next();
        assertNotNull( ol );

        li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        assertEquals( li.getFirstChild().asText().trim(), "Item 11." );
        li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        assertEquals( li.getFirstChild().asText().trim(), "Item 12." );
        li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        assertEquals( li.getFirstChild().asText().trim(), "Item 13." );
        li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        assertEquals( li.getFirstChild().asText().trim(), "Item 14." );
        li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        assertEquals( li.getFirstChild().asText().trim(), "Item 2." );
        li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        assertEquals( li.getFirstChild().asText().trim(), "Item 3." );
        li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        assertEquals( li.getFirstChild().asText().trim(), "Item 4." );

        ol = (HtmlOrderedList) elementIterator.next();
        assertNotNull( ol );

        li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        assertEquals( li.getFirstChild().asText().trim(), "Item 41." );
        li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        assertEquals( li.getFirstChild().asText().trim(), "Item 42." );
        li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        assertEquals( li.getFirstChild().asText().trim(), "Item 43." );
        li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        assertEquals( li.getFirstChild().asText().trim(), "Item 44." );

        p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );
        assertEquals( p.asText().trim(), "Paragraph 1 below list." );
        p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );
        assertEquals( p.asText().trim(), "Paragraph 2 below list." );
        p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );
        assertEquals( p.asText().trim(), "Paragraph 3 below list." );
        p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );
        assertEquals( p.asText().trim(), "Paragraph 4 below list." );
        p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );
        assertEquals( p.asText().trim(), "Paragraph 5 below list." );
        p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );
        assertEquals( p.asText().trim(), "Paragraph 6 below list." );

        // ----------------------------------------------------------------------
        // Definition lists
        // ----------------------------------------------------------------------
        div = (HtmlDivision) elementIterator.next();
        assertNotNull( div );
        assertEquals( div.getAttribute( "class" ), "section" );

        h4 = (HtmlHeading4) elementIterator.next();
        assertNotNull( h4 );
        assertEquals( h4.asText().trim(), "Definition lists" );
View Full Code Here

        HtmlPage page = htmlPage( file );
        assertNotNull( page );

        HtmlElement element = page.getHtmlElementById( "contentBox" );
        assertNotNull( element );
        HtmlDivision division = (HtmlDivision) element;
        assertNotNull( division );

        Iterator<HtmlElement> elementIterator = division.getHtmlElementDescendants().iterator();

        // ----------------------------------------------------------------------
        //
        // ----------------------------------------------------------------------

        HtmlDivision div = (HtmlDivision) elementIterator.next();
        assertEquals( "section", div.getAttribute( "class" ) );

        HtmlHeading2 h2 = (HtmlHeading2) elementIterator.next();
        assertNotNull( h2 );
        assertEquals( "Links", h2.asText().trim() );

        HtmlAnchor a = (HtmlAnchor) elementIterator.next();
        assertEquals( "Links", a.getAttribute( "name" ) );

        HtmlParagraph p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );

        // Expected log: [APT Parser] Ambiguous link: 'cdc.html'. If this is a local link, prepend "./"!
        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "Anchor", a.getAttribute( "name" ) );
        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "cdc.html", a.getAttribute( "name" ) );

        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "#Anchor", a.getAttribute( "href" ) );
        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "#Anchor", a.getAttribute( "href" ) );

        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "Anchor_with_space", a.getAttribute( "name" ) );
        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "#Anchor_with_space", a.getAttribute( "href" ) );

        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "http://maven.apache.org/", a.getAttribute( "href" ) );
        assertEquals( "externalLink", a.getAttribute( "class" ) );
        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "http://maven.apache.org/", a.getAttribute( "href" ) );
        assertEquals( "externalLink", a.getAttribute( "class" ) );

        // Expected log: [APT Parser] Ambiguous link: 'cdc.html'. If this is a local link, prepend "./"!
        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "./cdc.html", a.getAttribute( "href" ) );
        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "#cdc.html", a.getAttribute( "href" ) );

        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "/index.html", a.getAttribute( "href" ) );

        div = (HtmlDivision) elementIterator.next();
        assertEquals( "section", div.getAttribute( "class" ) );

        h2 = (HtmlHeading2) elementIterator.next();
        assertNotNull( h2 );
        // Note: htmlunit strips the white space, actual result is ok
        assertEquals( "Section formatting: italicboldmono", h2.asText().trim() );

        HtmlItalic italic = (HtmlItalic) elementIterator.next();
        assertEquals( "i", italic.getTagName() );
        assertEquals( "italic", italic.asText().trim() );

        HtmlBold bold = (HtmlBold) elementIterator.next();
        assertEquals( "b", bold.getTagName() );
        assertEquals( "bold", bold.asText().trim() );

        HtmlTeletype tt = (HtmlTeletype) elementIterator.next();
        assertEquals( "tt", tt.getTagName() );
        assertEquals( "mono", tt.asText().trim() );

        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "Section_formatting:_italic_bold_mono", a.getAttribute( "name" ) );

        div = (HtmlDivision) elementIterator.next();
        assertEquals( "section", div.getAttribute( "class" ) );

        HtmlHeading3 h3 = (HtmlHeading3) elementIterator.next();
        assertNotNull( h3 );
        // Note: htmlunit strips the white space, actual result is ok
        assertEquals( "SubSection formatting: italicboldmono", h3.asText().trim() );

        italic = (HtmlItalic) elementIterator.next();
        assertEquals( "i", italic.getTagName() );
        assertEquals( "italic", italic.asText().trim() );

        bold = (HtmlBold) elementIterator.next();
        assertEquals( "b", bold.getTagName() );
        assertEquals( "bold", bold.asText().trim() );

        tt = (HtmlTeletype) elementIterator.next();
        assertEquals( "tt", tt.getTagName() );
        assertEquals( "mono", tt.asText().trim() );

        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "SubSection_formatting:_italic_bold_mono", a.getAttribute( "name" ) );

        p = (HtmlParagraph) elementIterator.next();
        assertNotNull( p );

        italic = (HtmlItalic) elementIterator.next();
        assertEquals( "i", italic.getTagName() );
        assertEquals( "italic", italic.asText().trim() );

        bold = (HtmlBold) elementIterator.next();
        assertEquals( "b", bold.getTagName() );
        assertEquals( "bold", bold.asText().trim() );

        tt = (HtmlTeletype) elementIterator.next();
        assertEquals( "tt", tt.getTagName() );
        assertEquals( "mono", tt.asText().trim() );

        div = (HtmlDivision) elementIterator.next();
        assertEquals( "section", div.getAttribute( "class" ) );

        h2 = (HtmlHeading2) elementIterator.next();
        assertNotNull( h2 );
        assertEquals( "No Default Anchor in Section Title with Explicit Anchor", h2.asText().trim() );
        a = (HtmlAnchor) elementIterator.next();
        assertEquals( "No_Default_Anchor_in_Section_Title_with_Explicit_Anchor", a.getAttribute( "name" ) );

        div = (HtmlDivision) elementIterator.next();
        assertEquals( "section", div.getAttribute( "class" ) );
    }
View Full Code Here

                        // this obj won't have prototype, constants need to be configured on it again
                        configureConstants(config, obj);

                        if (obj.getClass() == Element.class && webWindow.getEnclosedPage() instanceof HtmlPage) {
                            final DomNode domNode =
                                new HtmlDivision(null, "", (SgmlPage) webWindow.getEnclosedPage(), null);
                            obj.setDomNode(domNode);
                        }
                    }
                    prototypes.put(config.getLinkedClass(), prototype);
                }
View Full Code Here

    public Object jsxFunction_createElementNS(final String namespaceURI, final String qualifiedName) {
        final org.w3c.dom.Element element;
        if (getBrowserVersion().isFirefox()
                && "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul".equals(namespaceURI)) {
            // simple hack, no need to implement the XUL objects (at least in a first time)
            element = new HtmlDivision(namespaceURI, qualifiedName, getPage(), null);
        }
        else if (HTMLParser.XHTML_NAMESPACE.equals(namespaceURI)) {
            element = getPage().createElementNS(namespaceURI, qualifiedName);
        }
        else {
View Full Code Here

      ejtt.sleep(2000);

      // Get the results table.
      //client.getElement("historyDetailsPanel_body");
      HtmlDivision resultsDiv = (HtmlDivision) client.getElement("operationResults");
      if( null == resultsDiv )
        throw new HtmlElementNotFoundException("#operationResults - a div around a results table.");

      HtmlTable resultsTableElm = resultsDiv.getFirstByXPath(".//table[@class='properties-table']");
      if( null == resultsTableElm )
        throw new HtmlElementNotFoundException(".//table[@class='properties-table'] - a results table.");
      ContentTable resultsTable = ejtt.getTabMenu().getTabContentBox().getTable(resultsTableElm);
     
      // Process the results table.
View Full Code Here

      ejtt.sleep(2000);

      // Get the results table.
      //client.getElement("historyDetailsPanel_body");
      HtmlDivision resultsDiv = (HtmlDivision) client.getElement("operationResults");
      if( null == resultsDiv )
        throw new HtmlElementNotFoundException("#operationResults - a div around a results table.");

      HtmlTable resultsTableElm = resultsDiv.getFirstByXPath(".//table[@class='properties-table']");
      if( null == resultsTableElm )
        throw new HtmlElementNotFoundException(".//table[@class='properties-table'] - a results table.");
      ContentTable resultsTable = ejtt.getTabMenu().getTabContentBox().getTable(resultsTableElm);

      // Process the results table.
View Full Code Here

    @Test
    @Ignore // broke with the jQuery 1.6.2 upgrade
    public void testServerClick() throws IOException, SAXException {
        HtmlPage page = environment.getPage("/dropDownMenu_serverMode.jsf");
        HtmlDivision item = (HtmlDivision) page.getElementById("form:saveAll");
        assertNotNull(item);
        DropDownMenuBean.setCurrent("none");
        item.click();

        item = (HtmlDivision) page.getElementById("form:saveAll");
        assertNotNull(item);
        assertEquals("action", DropDownMenuBean.getCurrent());
    }
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.html.HtmlDivision

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.