ClickAction extends FindElementAction { @Override protected void execute(WebElement webElement, SeleniumBrowser browser, TestContext context) { super.execute(webElement, browser, context); webElement.click(); } ClickAction(Builder builder);   }
@Test public void testExecute() throws Exception { when(webDriver.findElement(any(By.class))).thenAnswer(new Answer<WebElement>() { @Override public WebElement answer(InvocationOnMock invocation) throws Throwable { By select = (By) invocation.getArguments()[0]; Assert.assertEquals(select.getClass(), By.ById.class); Assert.assertEquals(select.toString(), "By.id: myButton"); return element; } }); ClickAction action = new ClickAction.Builder() .browser(seleniumBrowser) .element("id", "myButton") .build(); action.execute(context); verify(element).click(); }
@Test(expectedExceptions = CitrusRuntimeException.class, expectedExceptionsMessageRegExp = "Failed to find element 'id=myButton' on page") public void testElementNotFound() { when(webDriver.findElement(any(By.class))).thenReturn(null); ClickAction action = new ClickAction.Builder() .browser(seleniumBrowser) .element("id", "myButton") .build(); action.execute(context); }