HoverAction extends FindElementAction { @Override protected void execute(WebElement webElement, SeleniumBrowser browser, TestContext context) { super.execute(webElement, browser, context); Actions builder = new Actions(browser.getWebDriver()); builder.moveToElement(webElement).perform(); } HoverAction(Builder builder);   }
@Test public void testExecute() throws Exception { Mouse mouse = Mockito.mock(Mouse.class); Keyboard keyboard = Mockito.mock(Keyboard.class); Coordinates coordinates = Mockito.mock(Coordinates.class); when(webDriver.getMouse()).thenReturn(mouse); when(webDriver.getKeyboard()).thenReturn(keyboard); when(element.getCoordinates()).thenReturn(coordinates); when(webDriver.findElement(any(By.class))).thenReturn(element); HoverAction action = new HoverAction.Builder() .browser(seleniumBrowser) .element("id", "myButton") .build(); action.execute(context); }
@Test(expectedExceptions = CitrusRuntimeException.class, expectedExceptionsMessageRegExp = "Failed to find element 'id=myButton' on page") public void testElementNotFound() { when(webDriver.findElement(any(By.class))).thenReturn(null); HoverAction action = new HoverAction.Builder() .browser(seleniumBrowser) .element("id", "myButton") .build(); action.execute(context); }