@JavascriptEnabled @Test public void testDragAndDrop() throws InterruptedException { driver.get(pages.droppableItems); long waitEndTime = System.currentTimeMillis() + 15000; while (!isElementAvailable(driver, By.id("draggable")) && (System.currentTimeMillis() < waitEndTime)) { Thread.sleep(200); } if (!isElementAvailable(driver, By.id("draggable"))) { throw new RuntimeException("Could not find draggable element after 15 seconds."); } WebElement toDrag = driver.findElement(By.id("draggable")); WebElement dropInto = driver.findElement(By.id("droppable")); Action holdDrag = getBuilder(driver).clickAndHold(toDrag).build(); Action move = getBuilder(driver).moveToElement(dropInto).build(); Action drop = getBuilder(driver).release(dropInto).build(); holdDrag.perform(); move.perform(); drop.perform(); dropInto = driver.findElement(By.id("droppable")); String text = dropInto.findElement(By.tagName("p")).getText(); assertEquals("Dropped!", text); }
private void performDragAndDropWithMouse() { driver.get(pages.draggableLists); WebElement dragReporter = driver.findElement(By.id("dragging_reports")); WebElement toDrag = driver.findElement(By.id("rightitem-3")); WebElement dragInto = driver.findElement(By.id("sortable1")); Action holdItem = getBuilder(driver).clickAndHold(toDrag).build(); Action moveToSpecificItem = getBuilder(driver).moveToElement(driver.findElement(By.id("leftitem-4"))).build(); Action moveToOtherList = getBuilder(driver).moveToElement(dragInto).build(); Action drop = getBuilder(driver).release(dragInto).build(); assertEquals("Nothing happened.", dragReporter.getText()); try { holdItem.perform(); moveToSpecificItem.perform(); moveToOtherList.perform(); String text = dragReporter.getText(); assertTrue(text, text.matches("Nothing happened. (?:DragOut *)+")); } finally { drop.perform(); } }
public static void performAction(Action action) { for (Metrics metric : values()) { if (metric.isActive()) { action.perform(metric); } } }
public void runAction(Action f) { run( operationState -> { f.perform(operationState); return null; }); }
public void runOnce(Action f) { runOnce( Void.class, taskState -> { f.perform(taskState); return null; }); }
/* * Extracts the requested action and (depending on whether the user is logged in) * perform it (or make the user login). * @param request * @return the next page (the view) */ private String performTheAction(HttpServletRequest request) { HttpSession session = request.getSession(true); String servletPath = request.getServletPath(); String action = getActionName(servletPath); // System.out.println("servletPath="+servletPath+" requestURI="+request.getRequestURI()+" // user="+user); // Let the logged in user run his chosen action return Action.perform(action, request); }
@JavascriptEnabled @Test public void testDoubleClick() { driver.get(pages.javascriptPage); WebElement toDoubleClick = driver.findElement(By.id("doubleClickField")); Action dblClick = getBuilder(driver).doubleClick(toDoubleClick).build(); dblClick.perform(); String testFieldContent = shortWait.until(elementValueToEqual(toDoubleClick, "DoubleClicked")); assertEquals("Value should change to DoubleClicked.", "DoubleClicked", testFieldContent); }
@JavascriptEnabled @Test public void testDoubleClickThenGet() { // Fails in ff3 if WebLoadingListener removes browser listener driver.get(pages.javascriptPage); WebElement toClick = driver.findElement(By.id("clickField")); Action dblClick = getBuilder(driver).doubleClick(toClick).build(); dblClick.perform(); driver.get(pages.droppableItems); }
@Override protected void continuePreviousActions(Vehicle vehicle, TimeLapse time) { synchronized (this) { if (pendingVehicleActions.containsKey(vehicle)) { final Action action = pendingVehicleActions.get(vehicle); action.perform(time); if (action.isDone()) { pendingVehicleActions.remove(vehicle); checkState(!pendingVehicleActions.containsKey(vehicle)); checkState(vehicleState.get(vehicle) == VehicleState.IDLE); } } } }
@JavascriptEnabled @Ignore({CHROME, IE}) @Test public void testCannotMoveToANullLocator() { driver.get(pages.javascriptPage); try { Action contextClick = getBuilder(driver).moveToElement(null).build(); contextClick.perform(); fail("Shouldn't be allowed to click on null element."); } catch (IllegalArgumentException expected) { // Expected. } }
@JavascriptEnabled @Test public void testMoveAndClick() { driver.get(pages.javascriptPage); WebElement toClick = driver.findElement(By.id("clickField")); Action contextClick = getBuilder(driver).moveToElement(toClick).click().build(); contextClick.perform(); wait.until(elementValueToEqual(toClick, "Clicked")); assertEquals("Value should change to Clicked.", "Clicked", toClick.getAttribute("value")); }
@JavascriptEnabled @Test public void testContextClick() { driver.get(pages.javascriptPage); WebElement toContextClick = driver.findElement(By.id("doubleClickField")); Action contextClick = getBuilder(driver).contextClick(toContextClick).build(); contextClick.perform(); assertEquals( "Value should change to ContextClicked.", "ContextClicked", toContextClick.getAttribute("value")); }
/** performs PropertiesAction with this node */ public void properties() { propertiesAction.perform(this); }
public void edit() { editAction.perform(this); }
/** performs ViewAction with this node */ public void view() { viewAction.perform(this); }