Examples of HtmlDivision


Examples of com.gargoylesoftware.htmlunit.html.HtmlDivision

    @Test
    public void testCreateCardLinkWithJavascript() throws Exception {
        WebClient wc = startWebClient();
        login(wc);
        HtmlPage page = wc.getPage(url("/cards/Cards.action"));
        HtmlDivision cardDetailsDiv = page.getHtmlElementById("cardDetails");

        HtmlAnchor createCardLink = getFirstLinkByText(cardDetailsDiv, "Create a new card");
        createCardLink.click();
        assertNotNull(page.getHtmlElementById("createCardForm"));
    }
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.html.HtmlDivision

    public void testCreateCardLinkWithoutJavascript() throws Exception {
        WebClient wc = startWebClient();
        wc.setJavaScriptEnabled(false);
        login(wc);
        HtmlPage page = wc.getPage(url("/cards/Cards.action"));
        HtmlDivision cardDetailsDiv = page.getHtmlElementById("cardDetails");

        HtmlAnchor createCardLink = getFirstLinkByText(cardDetailsDiv, "Create a new card");
        HtmlPage createCardPage = createCardLink.click();
        testTitle(createCardPage, "Create a card");
        assertNotNull(createCardPage.getHtmlElementById("createCardForm"));
View Full Code Here

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();

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

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

        HtmlHeading2 h2 = (HtmlHeading2) elementIterator.next();
        assertEquals( h2.asText().trim(), "Oft Asked Questions" );

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

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

        HtmlParagraph p = (HtmlParagraph) elementIterator.next();
        element = elementIterator.next();
        assertEquals( element.getTagName(), "b" );
        assertEquals( element.asText().trim(), "Contributing" );

        HtmlOrderedList ol = (HtmlOrderedList) elementIterator.next();
        assertEquals( ol.getFirstChild().asText().trim(), "One stupid question & a silly answer?" );

        HtmlListItem li = (HtmlListItem) elementIterator.next();
        assertEquals( li.getFirstChild().asText().trim(), "One stupid question & a silly answer?" );

        a = (HtmlAnchor) elementIterator.next();
        assertEquals( a.getAttribute( "href" ), "#stupid-question" );

        element = elementIterator.next();
        assertEquals( element.getTagName(), "b" );
        assertEquals( element.asText().trim(), "stupid" );

        p = (HtmlParagraph) elementIterator.next();
        element = elementIterator.next();
        assertEquals( element.getTagName(), "b" );
        assertEquals( element.asText().trim(), "Using Maven" );

        ol = (HtmlOrderedList) elementIterator.next();
        assertEquals( ol.getFirstChild().asText().trim(), "How do I disable a report on my site?" );

        li = (HtmlListItem) elementIterator.next();
        assertNotNull( li );
        assertEquals( li.getFirstChild().asText().trim(), "How do I disable a report on my site?" );

        a = (HtmlAnchor) elementIterator.next();
        assertEquals( a.getAttribute( "href" ), "#disable-reports" );

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

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

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

        HtmlDefinitionList dl = (HtmlDefinitionList) elementIterator.next();

        HtmlDefinitionTerm dt = (HtmlDefinitionTerm) elementIterator.next();
        assertEquals( dt.getFirstChild().asText().trim(), "One stupid question & a silly answer?" );

        a = (HtmlAnchor) elementIterator.next();
        assertEquals( a.getAttribute( "name" ), "stupid-question" );

        element = elementIterator.next();
        assertEquals( element.getTagName(), "b" );
        assertEquals( element.asText().trim(), "stupid" );

        HtmlDefinitionDescription dd = (HtmlDefinitionDescription) elementIterator.next();

        p = (HtmlParagraph) elementIterator.next();

        a = (HtmlAnchor) elementIterator.next();
        assertEquals( a.getAttribute( "href" ), "#Using_Maven" );
        assertEquals( a.asText().trim(), "local link" );

        a = (HtmlAnchor) elementIterator.next();
        assertEquals( a.getAttribute( "href" ), "./cdc.html" );
        assertEquals( a.asText().trim(), "source document" );

        a = (HtmlAnchor) elementIterator.next();
        assertEquals( a.getAttribute( "href" ), "http://maven.apache.org/?l=a&m=b" );
        assertEquals( a.asText().trim(), "external link" );

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

        p = (HtmlParagraph) elementIterator.next();
        assertEquals( p.getAttribute( "align" ), "right" );

        a = (HtmlAnchor) elementIterator.next();
        assertEquals( a.getAttribute( "href" ), "#top" );
        assertEquals( a.asText().trim(), "[top]" );


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

        h2 = (HtmlHeading2) elementIterator.next();
        assertEquals( h2.asText().trim(), "Using Maven" );

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

        dl = (HtmlDefinitionList) elementIterator.next();

        dt = (HtmlDefinitionTerm) elementIterator.next();
        assertEquals( dt.getFirstChild().asText().trim(), "How do I disable a report on my site?" );

        a = (HtmlAnchor) elementIterator.next();
        assertEquals( a.getAttribute( "name" ), "disable-reports" );

        dd = (HtmlDefinitionDescription) elementIterator.next();

        p = (HtmlParagraph) elementIterator.next();

        element = elementIterator.next();
        assertEquals( element.getTagName(), "tt" );
        assertEquals( element.asText().trim(), "<source></source>" );

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

        HtmlPreformattedText pre = (HtmlPreformattedText) elementIterator.next();
        assertEquals( pre.asText().trim(), "<source>1.5</source>" );

        p = (HtmlParagraph) elementIterator.next();
View Full Code Here

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();

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

        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() );

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

        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() );

        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() );

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

        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() );

        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

Examples of com.gargoylesoftware.htmlunit.html.HtmlDivision

  public void testRichTree_AjaxSwitchType() throws IOException, InterruptedException
  {
    HtmlTree ajaxTree = (HtmlTree)server.findComponent(_AJAX_TREE_NAME);
    assertNotNull("Unable to find ajax tree component ["+_AJAX_TREE_NAME+"]",ajaxTree);

    HtmlDivision treeElement = (HtmlDivision)client.getElement(_AJAX_TREE_NAME);
    assertNotNull("Unable to find tree root DIV",treeElement);
   
    TreeNode data = (TreeNode)ajaxTree.getValue();
    assertNotNull("Unable to query for tree data",data);
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.html.HtmlDivision

  public void testRichTree_ServerSwitchType() throws IOException, InterruptedException
  {
    HtmlTree serverTree = (HtmlTree)server.findComponent(_SERVER_TREE_NAME);
    assertNotNull("Unable to find ajax tree component ["+_SERVER_TREE_NAME+"]",serverTree);

    HtmlDivision treeElement = (HtmlDivision)client.getElement(_SERVER_TREE_NAME);
    assertNotNull("Unable to find tree root DIV",treeElement);
   
    TreeNode data = (TreeNode)serverTree.getValue();
    assertNotNull("Unable to query for tree data",data);
   
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.html.HtmlDivision

   
    // 1) Find client-side tooltip span
    HtmlSpan tooltip1 = (HtmlSpan)((HtmlPage)client.getContentPage()).getElementById(_DEFAULT_CLIENTSIDE_TOOLTIP)// Required because name collision
    assertNotNull("Unable to find client-side span named \""+_DEFAULT_CLIENTSIDE_TOOLTIP+"\"",tooltip1);       
    // 2) Find Richpanel div to perform mouse-over (parent element)
    HtmlDivision parentDiv = (HtmlDivision)client.getElement(_DEFAULT_CLIENTSIDE_PANEL);
    assertNotNull("Unable to find \"sample1\" control",parentDiv);
    // 3) Find Richpanel internal div (also needed)
    HtmlDivision parentSubDiv = (HtmlDivision)client.getElement(_DEFAULT_CLIENTSIDE_PANEL+"_body");
    assertNotNull("Unable to find \"sample1_body\" control",parentSubDiv);
    // 4) Make sure tooltip is currently hidden (style contains 'display: none')
    String hiddenStyle = tooltip1.getStyleAttribute();
    assertTrue("Tooltip not hidden as expected: ["+hiddenStyle+"]",
        hiddenStyle.contains("display:none") || hiddenStyle.contains("display: none"));
    // 5) Move mouse over div to make tooltip display
    //   Yes, all three of these are required.
    parentDiv.mouseOver();
    parentDiv.mouseMove();
    parentSubDiv.mouseOver();

    // 6) Make sure tooltip is currently visible (style does not contain 'display: none')
    String visibleStyle = tooltip1.getStyleAttribute();
    assertFalse("Tooltip not visible as expected: ["+visibleStyle+"]",
        visibleStyle.contains("display:none") || visibleStyle.contains("display: none"));   
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.html.HtmlDivision

   
    // 1) Find client-side tooltip span
    HtmlSpan tooltip1 = (HtmlSpan)((HtmlPage)client.getContentPage()).getElementById(_FOLLOWMOUSE_TOOLTIP)// Required because name collision
    assertNotNull("Unable to find client-side span named \""+_FOLLOWMOUSE_TOOLTIP+"\"",tooltip1);       
    // 2) Find Richpanel div to perform mouse-over (parent element)
    HtmlDivision parentDiv = (HtmlDivision)client.getElement(_FOLLOWMOUSE_PANEL);
    assertNotNull("Unable to find \"sample1\" control",parentDiv);
    // 3) Find Richpanel internal div (also needed)
    HtmlDivision parentSubDiv = (HtmlDivision)client.getElement(_FOLLOWMOUSE_PANEL+"_body");
    assertNotNull("Unable to find \"sample1_body\" control",parentSubDiv);
    // 4) Make sure tooltip is currently hidden (style contains 'display: none')
    String hiddenStyle = tooltip1.getStyleAttribute();
    assertTrue("Tooltip not hidden as expected: ["+hiddenStyle+"]",
        hiddenStyle.contains("display:none") || hiddenStyle.contains("display: none"));
    // 5) Move mouse over div to make tooltip display
    //   Yes, all three of these are required.
    parentDiv.mouseOver();
    parentDiv.mouseMove();
    parentSubDiv.mouseOver();

    // 0.5 delay on tooltip - so wait a sec
    Thread.sleep(1000);
   
    // 6) Make sure tooltip is currently visible (style does not contain 'display: none')
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.html.HtmlDivision

    // Make sure we can lookup server component by name
    HtmlToolTip tt = (HtmlToolTip)server.findComponent(_SERVERREDNER_TOOLTIP);
    assertNotNull("Unable to find server-side HtmlToolTip component",tt);

    // 1) Server-side rendered tooltip seems to be a child div
    HtmlDivision tooltip1 = (HtmlDivision)((HtmlPage)client.getContentPage()).getElementById(_SERVERREDNER_TOOLTIP);
    assertNotNull("Unable to find client-side div named \""+_SERVERREDNER_TOOLTIP+"\"",tooltip1);

    // 2) Find Richpanel div to perform mouse-over (parent element)
    HtmlDivision parentDiv = (HtmlDivision)client.getElement(_SERVERREDNER_PANEL);
    assertNotNull("Unable to find \"sample1\" control",parentDiv);
    // 3) Find Richpanel internal div (also needed)
    HtmlDivision parentSubDiv = (HtmlDivision)client.getElement(_SERVERREDNER_PANEL+"_body");
    assertNotNull("Unable to find \"sample1_body\" control",parentSubDiv);
    // 4) Make sure tooltip is currently hidden (style contains 'display: none')
    String hiddenStyle = tooltip1.getStyleAttribute();
    assertTrue("Tooltip not hidden as expected: ["+hiddenStyle+"]",
        hiddenStyle.contains("display:none") || hiddenStyle.contains("display: none"));
    // 5) Lookup backing bean and current tooltip counter
    ToolTipData toolTipData = (ToolTipData)server.getManagedBeanValue("#{toolTipData}");
    assertNotNull("Couldn't find ToolTipData managed bean",toolTipData);
    int startVal = toolTipData.getTooltipCounterWithoutMod();
    //6) Move mouse over div to make tooltip display
    //   Yes, all three of these are required.
    parentDiv.mouseOver();
    parentDiv.mouseMove();
    parentSubDiv.mouseOver();

    // 0.5 delay on tooltip - so wait a sec
    Thread.sleep(1000);

    // 7) Make sure tooltip is currently visible (style does not contain 'display: none')
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.html.HtmlDivision

    // Make sure we can lookup server component by name
    HtmlToolTip tt = (HtmlToolTip)server.findComponent(_MOUSECLICK_TOOLTIP);
    assertNotNull("Unable to find server-side HtmlToolTip component",tt);

    // 1) Server-side rendered tooltip seems to be a child div
    HtmlDivision tooltip1 = (HtmlDivision)((HtmlPage)client.getContentPage()).getElementById(_MOUSECLICK_TOOLTIP);
    assertNotNull("Unable to find client-side div named \""+_MOUSECLICK_TOOLTIP+"\"",tooltip1);
    // 2) Find Richpanel div to perform mouse-over (parent element)
    HtmlDivision parentDiv = (HtmlDivision)client.getElement(_MOUSECLICK_PANEL);
    assertNotNull("Unable to find \"sample1\" control",parentDiv);
    // 3) Find Richpanel internal div (also needed)
    HtmlDivision parentSubDiv = (HtmlDivision)client.getElement(_MOUSECLICK_PANEL+"_body");
    assertNotNull("Unable to find \"sample1_body\" control",parentSubDiv);
    // 4) Make sure tooltip is currently hidden (style contains 'display: none')
    String hiddenStyle = tooltip1.getStyleAttribute();
    assertTrue("Tooltip not hidden as expected: ["+hiddenStyle+"]",
        hiddenStyle.contains("display:none") || hiddenStyle.contains("display: none"));
    // 5) Lookup backing bean and current tooltip counter
    ToolTipData toolTipData = (ToolTipData)server.getManagedBeanValue("#{toolTipData}");
    assertNotNull("Couldn't find ToolTipData managed bean",toolTipData);
    int startVal = toolTipData.getTooltipCounterWithoutMod();
    // 6) Move mouse over div to make tooltip display
    //   Yes, all three of these are required.
    parentDiv.mouseOver();
    parentDiv.mouseMove();
    parentSubDiv.mouseOver();
    parentSubDiv.click();   

    // 0.5 delay on tooltip - so wait a sec
    Thread.sleep(1000);

    // 7) Make sure tooltip is currently visible (style does not contain 'display: none')
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.