@Test public void shouldFailIfNoAlertIsPresent() { Mockito.when(targetLocator.alert()).thenThrow(new NoAlertPresentException()); final ExecuteResult result = action.execute(connectors); Assert.assertFalse(result.isSuccess()); }
@Override protected ExecuteResult execute(final WebSiteConnector connector) { try { final Alert alert = connector.getDriver().switchTo().alert(); if (this.action == Action.ACCEPT) { alert.accept(); LOGGER.info(LoggerMarkers.LEARNER, "Accept alert window."); } else { alert.dismiss(); LOGGER.info(LoggerMarkers.LEARNER, "Dismiss alert window."); } return getSuccessOutput(); } catch (NoAlertPresentException e) { LOGGER.info(LoggerMarkers.LEARNER, "Failed accept or dismiss alert window."); return getFailedOutput(); } }
AlertAcceptDismissAction extends WebSymbolAction { @Override protected ExecuteResult execute(final WebSiteConnector connector) { try { final Alert alert = connector.getDriver().switchTo().alert(); if (this.action == Action.ACCEPT) { alert.accept(); LOGGER.info(LoggerMarkers.LEARNER, "Accept alert window."); } else { alert.dismiss(); LOGGER.info(LoggerMarkers.LEARNER, "Dismiss alert window."); } return getSuccessOutput(); } catch (NoAlertPresentException e) { LOGGER.info(LoggerMarkers.LEARNER, "Failed accept or dismiss alert window."); return getFailedOutput(); } } }
AlertAcceptDismissAction extends WebSymbolAction { @Override protected ExecuteResult execute(final WebSiteConnector connector) { try { final Alert alert = connector.getDriver().switchTo().alert(); if (this.action == Action.ACCEPT) { alert.accept(); LOGGER.info(LoggerMarkers.LEARNER, "Accept alert window."); } else { alert.dismiss(); LOGGER.info(LoggerMarkers.LEARNER, "Dismiss alert window."); } return getSuccessOutput(); } catch (NoAlertPresentException e) { LOGGER.info(LoggerMarkers.LEARNER, "Failed accept or dismiss alert window."); return getFailedOutput(); } } AlertAcceptDismissAction(); }
AlertAcceptDismissAction extends WebSymbolAction { @Override protected ExecuteResult execute(final WebSiteConnector connector) { try { final Alert alert = connector.getDriver().switchTo().alert(); if (this.action == Action.ACCEPT) { alert.accept(); LOGGER.info(LoggerMarkers.LEARNER, "Accept alert window."); } else { alert.dismiss(); LOGGER.info(LoggerMarkers.LEARNER, "Dismiss alert window."); } return getSuccessOutput(); } catch (NoAlertPresentException e) { LOGGER.info(LoggerMarkers.LEARNER, "Failed accept or dismiss alert window."); return getFailedOutput(); } } AlertAcceptDismissAction(); Action getAction(); void setAction(Action action); }
AlertAcceptDismissAction extends WebSymbolAction { @Override protected ExecuteResult execute(final WebSiteConnector connector) { try { final Alert alert = connector.getDriver().switchTo().alert(); if (this.action == Action.ACCEPT) { alert.accept(); LOGGER.info(LoggerMarkers.LEARNER, "Accept alert window."); } else { alert.dismiss(); LOGGER.info(LoggerMarkers.LEARNER, "Dismiss alert window."); } return getSuccessOutput(); } catch (NoAlertPresentException e) { LOGGER.info(LoggerMarkers.LEARNER, "Failed accept or dismiss alert window."); return getFailedOutput(); } } AlertAcceptDismissAction(); Action getAction(); void setAction(Action action);  }