Package com.gargoylesoftware.htmlunit.html

Examples of com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScript()


public class BehaviorTest extends HudsonTestCase {
    public void testCssSelectors() throws Exception {
        HtmlPage p = createWebClient().goTo("self/testCssSelectors");

        // basic class selector, that we use the most often
        assertEquals(2,asInt(p.executeJavaScript("findElementsBySelector($('test1'),'.a',true).length")));
        assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test1'),'.a',false).length")));

        // 'includeSelf' should only affect the first axis and not afterward
        assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test2'),'.a .b',true).length")));
        assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test2'),'.a .b',false).length")));
View Full Code Here


    public void testCssSelectors() throws Exception {
        HtmlPage p = createWebClient().goTo("self/testCssSelectors");

        // basic class selector, that we use the most often
        assertEquals(2,asInt(p.executeJavaScript("findElementsBySelector($('test1'),'.a',true).length")));
        assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test1'),'.a',false).length")));

        // 'includeSelf' should only affect the first axis and not afterward
        assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test2'),'.a .b',true).length")));
        assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test2'),'.a .b',false).length")));
View Full Code Here

        // basic class selector, that we use the most often
        assertEquals(2,asInt(p.executeJavaScript("findElementsBySelector($('test1'),'.a',true).length")));
        assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test1'),'.a',false).length")));

        // 'includeSelf' should only affect the first axis and not afterward
        assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test2'),'.a .b',true).length")));
        assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test2'),'.a .b',false).length")));

        // tag.class. Should exclude itself anyway even if it's included
        assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test3'),'P.a',true).length")));
        assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test3'),'P.a',false).length")));
View Full Code Here

        assertEquals(2,asInt(p.executeJavaScript("findElementsBySelector($('test1'),'.a',true).length")));
        assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test1'),'.a',false).length")));

        // 'includeSelf' should only affect the first axis and not afterward
        assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test2'),'.a .b',true).length")));
        assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test2'),'.a .b',false).length")));

        // tag.class. Should exclude itself anyway even if it's included
        assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test3'),'P.a',true).length")));
        assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test3'),'P.a',false).length")));
    }
View Full Code Here

        // 'includeSelf' should only affect the first axis and not afterward
        assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test2'),'.a .b',true).length")));
        assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test2'),'.a .b',false).length")));

        // tag.class. Should exclude itself anyway even if it's included
        assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test3'),'P.a',true).length")));
        assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test3'),'P.a',false).length")));
    }

    private int asInt(ScriptResult r) {
        return ((Double)r.getJavaScriptResult()).intValue();
View Full Code Here

        assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test2'),'.a .b',true).length")));
        assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test2'),'.a .b',false).length")));

        // tag.class. Should exclude itself anyway even if it's included
        assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test3'),'P.a',true).length")));
        assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test3'),'P.a',false).length")));
    }

    private int asInt(ScriptResult r) {
        return ((Double)r.getJavaScriptResult()).intValue();
    }
View Full Code Here

     * even when multiple nodes are added.
     */
    public void testBehaviour() throws Exception {
        HtmlPage p = createWebClient().goTo("self/testBehaviour");

        p.executeJavaScript("renderOnDemand(document.getElementsBySelector('.lazy')[0])");
        // all AJAX calls complete before the above method returns

        ScriptResult r = p.executeJavaScript("var r=document.getElementsBySelector('DIV.a'); r[0].innerHTML+r[1].innerHTML+r[2].innerHTML");
        assertEquals("AlphaBravoCharlie",r.getJavaScriptResult().toString());
    }
View Full Code Here

        HtmlPage p = createWebClient().goTo("self/testBehaviour");

        p.executeJavaScript("renderOnDemand(document.getElementsBySelector('.lazy')[0])");
        // all AJAX calls complete before the above method returns

        ScriptResult r = p.executeJavaScript("var r=document.getElementsBySelector('DIV.a'); r[0].innerHTML+r[1].innerHTML+r[2].innerHTML");
        assertEquals("AlphaBravoCharlie",r.getJavaScriptResult().toString());
    }
}
View Full Code Here

        verifyTotal(webClient, jsCoverPage, 15, branchPercentage1, functionPercentage1);

        page.getHtmlElementById("radio3").click();
        webClient.waitForBackgroundJavaScript(100);

        jsCoverPage.executeJavaScript("jscoverage_recalculateSummaryTab();");
        webClient.waitForBackgroundJavaScript(500);
        verifyTotal(webClient, jsCoverPage, 73, branchPercentage2, functionPercentage2);
    }

    @Test
View Full Code Here

        assertThat(frame.getByXPath("//span[contains(@class,'failed')]").size(), equalTo(0));
        assertThat(frame.getByXPath("//span[contains(@class,'skipped')]").size(), equalTo(0));
        assertThat(passed.get(0).asText(), equalTo("16 specs, 0 failures"));

        //Store Report
        ScriptResult result = frame.executeJavaScript("jscoverage_report();");

        //Verify coverage
        page.getHtmlElementById("summaryTab").click();
        webClient.waitForBackgroundJavaScript(2000);
        assertEquals("100%", page.getElementById("summaryTotal").getTextContent());
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.