List of usage examples for org.openqa.selenium.interactions Actions moveToElement
public Actions moveToElement(WebElement target, int xOffset, int yOffset)
From source file:com.ibm.watson.app.qaclassifier.selenium.MenuIT.java
License:Open Source License
@Test public void clickingOnMenuContentDoesNotCloseOverlay() { WebElement menuIconContainer = driver.findElement(By.id("menuIconContainerDesktop")); WebElement menuIconImg = menuIconContainer .findElement(By.xpath(".//span[contains(concat(' ', @class, ' '), ' menuIconImg ')]")); menuIconImg.click();//w w w . j a v a 2s.c o m WebElement menuList = driver.findElement(By.className("menu-list")); List<WebElement> menuOptions = menuList.findElements(By.xpath(".//ul/li")); // The first item should be home, which is hidden on Desktop, so skip it and do the second one WebElement firstMenuOption = menuOptions.get(2); firstMenuOption.click(); // Click inside of the content WebElement menuOverlay = driver.findElement(By.id("menuOverlay")); WebElement menuContent = menuOverlay.findElement(By.xpath(".//div[@id='menu']")); Actions action = new Actions(driver); action.moveToElement(menuContent, 1, 1); action.click().build().perform(); assertTrue("Clicking inside of the content does not close the menu overlay", driver.findElements(By.id("menuOverlay")).size() == 1); }
From source file:com.liferay.cucumber.selenium.BaseWebDriverImpl.java
License:Open Source License
@Override public void doubleClickAt(String locator, String coordString) { WebElement webElement = getWebElement(locator); WrapsDriver wrapsDriver = (WrapsDriver) webElement; WebDriver webDriver = wrapsDriver.getWrappedDriver(); Actions actions = new Actions(webDriver); if (Validator.isNotNull(coordString) && coordString.contains(",")) { String[] coords = coordString.split(","); int x = GetterUtil.getInteger(coords[0]); int y = GetterUtil.getInteger(coords[1]); actions.moveToElement(webElement, x, y); actions.doubleClick();//from w w w . j ava2 s .c om } else { actions.doubleClick(webElement); } Action action = actions.build(); action.perform(); }
From source file:com.liferay.cucumber.selenium.BaseWebDriverImpl.java
License:Open Source License
@Override public void mouseDownAt(String locator, String coordString) { WebElement webElement = getWebElement(locator); scrollWebElementIntoView(webElement); WrapsDriver wrapsDriver = (WrapsDriver) webElement; WebDriver webDriver = wrapsDriver.getWrappedDriver(); Actions actions = new Actions(webDriver); if (Validator.isNotNull(coordString) && coordString.contains(",")) { String[] coords = coordString.split(","); int x = GetterUtil.getInteger(coords[0]); int y = GetterUtil.getInteger(coords[1]); actions.moveToElement(webElement, x, y); actions.clickAndHold();//w ww .j a v a2 s. c om } else { actions.moveToElement(webElement); actions.clickAndHold(webElement); } Action action = actions.build(); action.perform(); }
From source file:com.liferay.cucumber.selenium.BaseWebDriverImpl.java
License:Open Source License
@Override public void mouseMoveAt(String locator, String coordString) { WebElement webElement = getWebElement(locator); scrollWebElementIntoView(webElement); WrapsDriver wrapsDriver = (WrapsDriver) webElement; WebDriver webDriver = wrapsDriver.getWrappedDriver(); Actions actions = new Actions(webDriver); if (Validator.isNotNull(coordString) && coordString.contains(",")) { String[] coords = coordString.split(","); int x = GetterUtil.getInteger(coords[0]); int y = GetterUtil.getInteger(coords[1]); actions.moveToElement(webElement, x, y); } else {/*from w ww. jav a 2 s. c o m*/ actions.moveToElement(webElement); } Action action = actions.build(); action.perform(); }
From source file:com.liferay.cucumber.selenium.BaseWebDriverImpl.java
License:Open Source License
@Override public void mouseUpAt(String locator, String coordString) { WebElement webElement = getWebElement(locator); scrollWebElementIntoView(webElement); WrapsDriver wrapsDriver = (WrapsDriver) webElement; WebDriver webDriver = wrapsDriver.getWrappedDriver(); Actions actions = new Actions(webDriver); if (Validator.isNotNull(coordString) && coordString.contains(",")) { String[] coords = coordString.split(","); int x = GetterUtil.getInteger(coords[0]); int y = GetterUtil.getInteger(coords[1]); actions.moveToElement(webElement, x, y); actions.release();// w ww . j a v a 2s. c o m } else { actions.moveToElement(webElement); actions.release(webElement); } Action action = actions.build(); action.perform(); }
From source file:com.liferay.faces.test.selenium.browser.internal.BrowserDriverImpl.java
License:Open Source License
@Override public Actions createActions(String elementXpath) { if (windowHeight == null) { Long windowHeightLong = (Long) executeScriptInCurrentWindow( "return document.documentElement.clientHeight || window.innerHeight;"); windowHeight = windowHeightLong.intValue(); }//from www . j ava 2 s. co m WebElement webElement = findElementByXpath(elementXpath); Dimension elementSize = webElement.getSize(); int elementHeight = elementSize.getHeight(); Actions actions = createActions(); return actions.moveToElement(webElement, 0, -(windowHeight / 2) + (elementHeight / 2)); }
From source file:com.livejournal.uisteps.core.Browser.java
License:Apache License
public void clickOnPoint(WrapsElement element, int x, int y) { try {// ww w. j a v a 2 s.c o m Actions actions = new Actions(getDriver()); actions.moveToElement(element.getWrappedElement(), x, y).click().build().perform(); } catch (Exception ex) { Assert.fail("Cannot click " + element + "on point (" + x + "; " + y + ") \n" + ex); } }
From source file:com.pentaho.ctools.utils.ElementHelper.java
License:Apache License
/** * This method shall perform the MoveToElement wrap function of WebDriver. * We have to do this wrap to avoid StaleElement exceptions. * /* ww w. j a v a 2 s . co m*/ * @param driver * @param toLocator * @param xOffset * @param yOffset */ public void MoveToElement(final WebDriver driver, final By toLocator, final int xOffset, final int yOffset) { this.log.debug("MoveToElement::Enter"); try { WebElement element = WaitForElementPresenceAndVisible(driver, toLocator); if (element != null) { Actions acts = new Actions(driver); acts.moveToElement(element, xOffset, yOffset); acts.build().perform(); } else { this.log.warn("Element null!"); } } catch (StaleElementReferenceException sere) { this.log.warn("Stale Element Reference Exception"); MoveToElement(driver, toLocator, xOffset, yOffset); } this.log.debug("MoveToElement::Exit"); }
From source file:com.uisteps.core.user.browser.Browser.java
License:Apache License
public void clickOnPoint(WrapsElement element, int x, int y) { try {/* w ww . j a v a2 s . c o m*/ Actions actions = new Actions(getDriver()); actions.moveToElement(element.getWrappedElement(), x, y).click().build().perform(); } catch (Exception ex) { throw new AssertionError("Cannot click " + element + "on point (" + x + "; " + y + ") !\n" + ex); } }
From source file:com.vaadin.testbench.elements.WindowElement.java
License:Apache License
/** * Moves the window by given offset.//from w ww. ja v a 2 s . c o m * * @param xOffset * x offset * @param yOffset * y offset */ public void move(int xOffset, int yOffset) { Actions action = new Actions(getDriver()); action.moveToElement(findElement(org.openqa.selenium.By.className("v-window-wrap")), 5, 5); action.clickAndHold(); action.moveByOffset(xOffset, yOffset); action.release(); action.build().perform(); }