@Test public void shouldDragItemValid() throws InterruptedException { scrollByOffset(0, 300); for (int i = items.size(); i > 0; i--) { boolean shouldNotFound = false; WebElement e = findElementBySelector(source, ".ui-draggable > .ui-widget-header:nth-last-child(n)"); String text = e.getText(); action.dndToElement(e, dropArea); waitUntilAjaxRequestCompletes(); source = findElementBySelector( form, escapeClientId("carForm:availableCarsField") + " " + escapeClientId("carForm:availableCars")); target = findElementBySelector(form, escapeClientId("carForm:selectedCars")); dropArea = findElementBySelector(target, escapeClientId("carForm:dropArea")); try { findElementByXpath( source, "//div[contains(@class, 'ui-draggable')]//div[contains(@class, 'ui-widget-header')][contains(.,'" + text + "')]"); } catch (NoSuchElementException ex) { shouldNotFound = true; } if (!shouldNotFound) { assertTrue(shouldNotFound); } try { findElementByXpath( dropArea, "//div[contains(@class, 'ui-dt-c')][contains(.,'" + text + "')]"); } catch (NoSuchElementException ex) { assertTrue("DnD DataGrid should provide valid interactions.", false); } } }
@Test public void shouldDragItemInvalid() throws InterruptedException { for (WebElement e : items) { Point ps = e.getLocation(); action.dndByOffset(e, -50, -50); Thread.sleep(1000); Point pe = e.getLocation(); // should return startup position if (ps.x != pe.x || ps.y != pe.y) { assertTrue(false); } } }