Esempio n. 1
0
 @JavascriptEnabled
 @Ignore({HTMLUNIT, CHROME, SELENESE})
 public void testElementInDiv() {
   driver.get(dragAndDropPage);
   RenderedWebElement img = (RenderedWebElement) driver.findElement(By.id("test3"));
   Point expectedLocation = img.getLocation();
   drag(img, expectedLocation, 100, 100);
   assertEquals(expectedLocation, img.getLocation());
 }
Esempio n. 2
0
 @JavascriptEnabled
 @Ignore({HTMLUNIT, CHROME, SELENESE})
 public void testDragAndDropToElement() {
   driver.get(dragAndDropPage);
   RenderedWebElement img1 = (RenderedWebElement) driver.findElement(By.id("test1"));
   RenderedWebElement img2 = (RenderedWebElement) driver.findElement(By.id("test2"));
   img2.dragAndDropOn(img1);
   assertEquals(img1.getLocation(), img2.getLocation());
 }
Esempio n. 3
0
  @JavascriptEnabled
  @Ignore({HTMLUNIT, IE, CHROME, SELENESE})
  public void testDragTooFar() {
    driver.get(dragAndDropPage);
    RenderedWebElement img = (RenderedWebElement) driver.findElement(By.id("test1"));
    //        Point expectedLocation = img.getLocation();

    img.dragAndDropBy(Integer.MIN_VALUE, Integer.MIN_VALUE);
    assertEquals(new Point(0, 0), img.getLocation());

    img.dragAndDropBy(Integer.MAX_VALUE, Integer.MAX_VALUE);
    // We don't know where the img is dragged to , but we know it's not too
    // far, otherwise this function will not return for a long long time
  }
Esempio n. 4
0
  @JavascriptEnabled
  @Ignore({HTMLUNIT, IE, CHROME, SELENESE})
  public void testShouldAllowUsersToDragAndDropToElementsOffTheCurrentViewPort() {
    driver.get(dragAndDropPage);

    JavascriptExecutor js = (JavascriptExecutor) driver;
    Long height = (Long) js.executeScript("return window.outerHeight;");
    Long width = (Long) js.executeScript("return window.outerWidth;");
    js.executeScript("window.resizeTo(300, 300);");

    try {
      driver.get(dragAndDropPage);
      RenderedWebElement img = (RenderedWebElement) driver.findElement(By.id("test3"));
      Point expectedLocation = img.getLocation();
      drag(img, expectedLocation, 100, 100);
      assertEquals(expectedLocation, img.getLocation());
    } finally {
      js.executeScript("window.resizeTo(arguments[0], arguments[1]);", width, height);
    }
  }
Esempio n. 5
0
 @JavascriptEnabled
 @Ignore({HTMLUNIT, CHROME, SELENESE})
 public void testDragAndDrop() throws Exception {
   driver.get(dragAndDropPage);
   RenderedWebElement img = (RenderedWebElement) driver.findElement(By.id("test1"));
   Point expectedLocation = img.getLocation();
   drag(img, expectedLocation, 150, 200);
   assertEquals(expectedLocation, img.getLocation());
   driver.manage().setSpeed(Speed.SLOW);
   drag(img, expectedLocation, -50, -25);
   assertEquals(expectedLocation, img.getLocation());
   driver.manage().setSpeed(Speed.MEDIUM);
   drag(img, expectedLocation, 0, 0);
   assertEquals(expectedLocation, img.getLocation());
   driver.manage().setSpeed(Speed.FAST);
   drag(img, expectedLocation, 1, -1);
   assertEquals(expectedLocation, img.getLocation());
 }
Esempio n. 6
0
 private void drag(
     RenderedWebElement elem, Point expectedLocation, int moveRightBy, int moveDownBy) {
   elem.dragAndDropBy(moveRightBy, moveDownBy);
   expectedLocation.move(expectedLocation.x + moveRightBy, expectedLocation.y + moveDownBy);
 }