com.gargoylesoftware.htmlunit.ConfirmHandler Java Examples
The following examples show how to use
com.gargoylesoftware.htmlunit.ConfirmHandler.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HiddenHtmlConfirm.java From ats-framework with Apache License 2.0 | 6 votes |
@Override @PublicAtsApi public void clickOk() { isProcessed = false; webClient.setConfirmHandler(new ConfirmHandler() { @Override public boolean handleConfirm( Page currentPage, String confirmationText ) { isProcessed = true; return true; } }); }
Example #2
Source File: HiddenHtmlConfirm.java From ats-framework with Apache License 2.0 | 6 votes |
@Override @PublicAtsApi public void clickOk( final String expectedConfirmText ) { isProcessed = false; webClient.setConfirmHandler(new ConfirmHandler() { @Override public boolean handleConfirm( Page currentPage, String confirmationText ) { isProcessed = true; if (!confirmationText.equals(expectedConfirmText)) { throw new VerificationException("The expected confirm message was: '" + expectedConfirmText + "', but actually it is: '" + confirmationText + "'"); } return true; } }); }
Example #3
Source File: HiddenHtmlConfirm.java From ats-framework with Apache License 2.0 | 6 votes |
@Override @PublicAtsApi public void clickCancel() { isProcessed = false; webClient.setConfirmHandler(new ConfirmHandler() { @Override public boolean handleConfirm( Page currentPage, String confirmationText ) { isProcessed = true; return false; } }); }
Example #4
Source File: HiddenHtmlConfirm.java From ats-framework with Apache License 2.0 | 6 votes |
@Override @PublicAtsApi public void clickCancel( final String expectedConfirmText ) { isProcessed = false; webClient.setConfirmHandler(new ConfirmHandler() { @Override public boolean handleConfirm( Page currentPage, String confirmationText ) { isProcessed = true; if (!confirmationText.equals(expectedConfirmText)) { throw new VerificationException("The expected confirm message was: '" + expectedConfirmText + "', but actually it is: '" + confirmationText + "'"); } return false; } }); }
Example #5
Source File: Window.java From htmlunit with Apache License 2.0 | 5 votes |
/** * The JavaScript function {@code confirm}. * @param message the message * @return true if ok was pressed, false if cancel was pressed */ @JsxFunction public boolean confirm(final String message) { final ConfirmHandler handler = getWebWindow().getWebClient().getConfirmHandler(); if (handler == null) { if (LOG.isWarnEnabled()) { LOG.warn("window.confirm(\"" + message + "\") no confirm handler installed, simulating the OK button"); } return true; } return handler.handleConfirm(document_.getPage(), message); }
Example #6
Source File: WindowTest.java From htmlunit with Apache License 2.0 | 5 votes |
/** * @throws Exception if the test fails */ @Test public void confirm() throws Exception { final WebClient webClient = getWebClient(); final MockWebConnection webConnection = new MockWebConnection(); final List<String> collectedAlerts = new ArrayList<>(); final List<String> collectedConfirms = new ArrayList<>(); webClient.setAlertHandler(new CollectingAlertHandler(collectedAlerts)); webClient.setConfirmHandler(new ConfirmHandler() { @Override public boolean handleConfirm(final Page page, final String message) { collectedConfirms.add(message); return true; } }); final String firstContent = "<html><head><title>First</title><script>function doTest() {alert(confirm('foo'))}</script>\n" + "</head><body onload='doTest()'></body></html>"; webConnection.setResponse(URL_FIRST, firstContent); webClient.setWebConnection(webConnection); final HtmlPage firstPage = webClient.getPage(URL_FIRST); assertEquals("First", firstPage.getTitleText()); assertEquals(new String[] {"foo"}, collectedConfirms); assertEquals(new String[] {"true"}, collectedAlerts); }
Example #7
Source File: Window.java From HtmlUnit-Android with Apache License 2.0 | 5 votes |
/** * The JavaScript function {@code confirm}. * @param message the message * @return true if ok was pressed, false if cancel was pressed */ @JsxFunction public boolean confirm(final String message) { final ConfirmHandler handler = getWebWindow().getWebClient().getConfirmHandler(); if (handler == null) { LOG.warn("window.confirm(\"" + message + "\") no confirm handler installed, simulating the OK button"); return true; } return handler.handleConfirm(document_.getPage(), message); }