List of usage examples for org.openqa.selenium.interactions Actions Actions
public Actions(WebDriver driver)
From source file:com.vaadin.addon.charts.testbenchtests.RangeSelectorCustomDateParserTBTest.java
private void setRangeValue(String value, WebElement input) { Actions action = new Actions(driver); //Should be done as one action, otherwise does not work action.doubleClick(input).sendKeys(Keys.chord(Keys.CONTROL, "a")).sendKeys(Keys.BACK_SPACE).sendKeys(value) .sendKeys(Keys.TAB).perform(); }
From source file:com.vaadin.testbench.elements.MenuBarElement.java
License:Apache License
private void activateOrOpenSubmenu(WebElement item, boolean alwaysClick) { if (lastItemLocationMovedTo == null || !isAnySubmenuVisible()) { item.click();/*from w ww. j a v a 2 s .c o m*/ if (hasSubmenu(item)) { lastItemLocationMovedTo = item.getLocation(); } return; } // Assumes mouse is still at position of last clicked element Actions action = new Actions(getDriver()); action.moveToElement(item); action.build().perform(); if (isLeaf(item) || isSelectedTopLevelItem(item)) { lastItemLocationMovedTo = null; } else { lastItemLocationMovedTo = item.getLocation(); } if (alwaysClick || isLeaf(item) || !isAnySubmenuVisible()) { action = new Actions(getDriver()); action.click(); action.build().perform(); } }
From source file:com.vaadin.testbench.elements.TableElement.java
License:Apache License
@Override public void contextClick() { WebElement tbody = findElement(By.className("v-table-body")); // There is a problem in with phantomjs driver, just calling // contextClick() doesn't work. We have to use javascript. if (isPhantomJS()) { JavascriptExecutor js = getCommandExecutor(); String scr = "var element=arguments[0];" + "var ev = document.createEvent('HTMLEvents');" + "ev.initEvent('contextmenu', true, false);" + "element.dispatchEvent(ev);"; js.executeScript(scr, tbody);//from w w w . j a v a2s .c om } else { new Actions(getDriver()).contextClick(tbody).build().perform(); } }
From source file:com.vaadin.testbench.elements.WindowElement.java
License:Apache License
/** * Moves the window by given offset./* ww w .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(); }
From source file:com.vaadin.testbench.TestBenchElement.java
@Override public void showTooltip() { waitForVaadin();/* w ww .ja v a2s . c o m*/ new Actions(getCommandExecutor().getWrappedDriver()).moveToElement(actualElement).perform(); // Wait for a small moment for the tooltip to appear try { Thread.sleep(1000); // VTooltip.OPEN_DELAY = 750; } catch (InterruptedException ignored) { } }
From source file:com.vaadin.testbench.TestBenchElement.java
@Override public void click(int x, int y, Keys... modifiers) { waitForVaadin();/*from w w w . j a v a2 s . c om*/ Actions actions = new Actions(getCommandExecutor().getWrappedDriver()); actions.moveToElement(actualElement, x, y); // Press any modifier keys for (Keys modifier : modifiers) { actions.keyDown(modifier); } actions.click(); // Release any modifier keys for (Keys modifier : modifiers) { actions.keyUp(modifier); } actions.build().perform(); }
From source file:com.vaadin.testbench.TestBenchElement.java
public void doubleClick() { waitForVaadin();/*w w w .ja v a 2s . com*/ new Actions(getDriver()).doubleClick(actualElement).build().perform(); // Wait till vaadin component will process the event. Without it may // cause problems with phantomjs }
From source file:com.vaadin.testbench.TestBenchElement.java
public void contextClick() { waitForVaadin();// w w w . jav a 2s . com new Actions(getDriver()).contextClick(actualElement).build().perform(); // Wait till vaadin component will process the event. Without it may // cause problems with phantomjs }
From source file:com.vaadin.tests.components.calendar.CalendarActionEventSourceTest.java
License:Apache License
private void performAction(WebElement element) { // right click new Actions(getDriver()).contextClick(element).perform(); WebElement menuItem = getDriver().findElement(By.className("gwt-MenuItem")); menuItem.click();/* w w w . j av a 2 s . c o m*/ }
From source file:com.vaadin.tests.components.calendar.CalendarNotificationsTest.java
License:Apache License
@Test public void notificationTest() throws Exception { openTestURL();//w ww . j a v a 2s. c om WebElement day = findElements(By.className("v-calendar-day-number")).get(2); // IE8 requires you to click on the text part to fire the event new Actions(getDriver()).moveToElement(day, 83, 11).click().perform(); Assert.assertTrue("There should be a notification", $(NotificationElement.class).exists()); // move the mouse around a bit new Actions(getDriver()).moveByOffset(5, 5).moveByOffset(100, 100).perform(); // wait until the notification has animated out sleep(1000); Assert.assertFalse("There should be no notification on the page", $(NotificationElement.class).exists()); }