DecoratedTargetLocator extends DecoratedChild<WebDriver.TargetLocator,DecoratedWebDriver> implements WebDriver.TargetLocator { @Override public Alert alert() { return getTopmostDecorated().createDecorated(getOriginal().alert()).getActivated(); } DecoratedTargetLocator(final WebDriver.TargetLocator targetLocator, final DecoratedWebDriver driverWrapper); @Override WebDriver frame(int frameIndex); @Override WebDriver frame(String frameName); @Override WebDriver frame(WebElement frameElement); @Override WebDriver parentFrame(); @Override WebDriver window(String windowName); @Override WebDriver defaultContent(); @Override WebElement activeElement(); @Override Alert alert();  }
@Test void testAlert() { Alert alert = mock(Alert.class); verifyDecoratingFunction(WebDriver.TargetLocator::alert, alert, Alert::dismiss); }