Package com.gargoylesoftware.htmlunit

Examples of com.gargoylesoftware.htmlunit.AlertHandler


    protected void setupWebClient() {
        super.setupWebClient();
        webClient.setJavaScriptEngine(new JavaScriptEngine(webClient));
        webClient.setScriptPreProcessor(new UnescapingScriptPreprocessor());
        webClient.setThrowExceptionOnScriptError(true);
        webClient.setAlertHandler(new AlertHandler() {
            public void handleAlert(Page page, String message) {
                fail(message);
            }
        });
    }
View Full Code Here


     */
    @Bug(3415)
    public void testXSS() throws Exception {
        try {
            WebClient wc = new WebClient();
            wc.setAlertHandler(new AlertHandler() {
                public void handleAlert(Page page, String message) {
                    throw new AssertionError();
                }
            });
            wc.search("<script>alert('script');</script>");
View Full Code Here

        "http://foo.test/foo/test.Module.nocache.js"), testScript.toString(),
        "application/javascript");
    webClient.setWebConnection(webConnection);

    final List<String> alerts = new ArrayList<String>();
    webClient.setAlertHandler(new AlertHandler() {
      @Override
      public void handleAlert(Page page, String msg) {
        alerts.add(msg);
      }
    });
View Full Code Here

        } else {
            assertThat(branchCell.asText(), equalTo("info"));
            HtmlAnchor anchor = (HtmlAnchor) branchCell.getFirstChild().getFirstChild();

            final String alert[] = new String[1];
            webClient.setAlertHandler(new AlertHandler() {
                public void handleAlert(Page page, String message) {
                    alert[0] = message;
                }
            });
View Full Code Here

                Page page = createHtmlPage(wr, ww);
                return page;
            }
        });
        firephoque.setThrowExceptionOnFailingStatusCode(false);
        firephoque.setAlertHandler(new AlertHandler() {
            public void handleAlert(Page page, String string) {
                try {
                    Window window = (Window)page.getEnclosingWindow().getScriptObject();
                    window.custom_eval(
                        "parent.selenium.browserbot.recordedAlerts.push('" + string.replace("'", "\\'")+ "');"
View Full Code Here

  protected void setupWebClient() {
    super.setupWebClient();
    webClient.setJavaScriptEngine(new JavaScriptEngine(webClient));
    webClient.setScriptPreProcessor(new UnescapingScriptPreprocessor());
    webClient.setThrowExceptionOnScriptError(true);
    webClient.setAlertHandler(new AlertHandler() {

      public void handleAlert(Page page, String message) {
        fail(message);
      }
    });
View Full Code Here

                Page page = createHtmlPage(wr, ww);
                return page;
            }
        });
        firephoque.setThrowExceptionOnFailingStatusCode(false);
        firephoque.setAlertHandler(new AlertHandler() {
            public void handleAlert(Page page, String string) {
                try {
                    Window window = (Window)page.getEnclosingWindow().getScriptObject();
                    window.custom_eval(
                        "parent.selenium.browserbot.recordedAlerts.push('" + string.replace("'", "\\'")+ "');"
View Full Code Here

     */
    public void jsxFunction_alert(final Object message) {
        // use Object as parameter and perform String conversion by ourself
        // this allows to place breakpoint here and "see" the message object and its properties
        final String stringMessage = Context.toString(message);
        final AlertHandler handler = getWebWindow().getWebClient().getAlertHandler();
        if (handler == null) {
            LOG.warn("window.alert(\"" + stringMessage + "\") no alert handler installed");
        }
        else {
            handler.handleAlert(document_.getHtmlPage(), stringMessage);
        }
    }
View Full Code Here

            }
        });
       
        firephoque.getOptions().setThrowExceptionOnFailingStatusCode(false);
       
        firephoque.setAlertHandler(new AlertHandler() {
            public void handleAlert(Page page, String message) {
                try {
                    Window window = (Window)page.getEnclosingWindow().getScriptObject();
                    String script = "parent.selenium.browserbot.recordedAlerts.push('" + message.replace("'", "\\'")+ "');";
                    window.execScript(script,  "JavaScript");
View Full Code Here

                Page page = createHtmlPage(wr, ww);
                return page;
            }
        });
        firephoque.setThrowExceptionOnFailingStatusCode(false);
        firephoque.setAlertHandler(new AlertHandler() {
            public void handleAlert(Page page, String string) {
                try {
                    Window window = (Window)page.getEnclosingWindow().getScriptObject();
                    window.custom_eval(
                        "parent.selenium.browserbot.recordedAlerts.push('" + string.replace("'", "\\'")+ "');"
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.AlertHandler

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.