コード例 #1
0
ファイル: DragAndDropTest.java プロジェクト: epall/selenium
 @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());
 }
コード例 #2
0
ファイル: DragAndDropTest.java プロジェクト: epall/selenium
 @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());
 }
コード例 #3
0
ファイル: DragAndDropTest.java プロジェクト: epall/selenium
 @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());
 }
コード例 #4
0
ファイル: DragAndDropTest.java プロジェクト: epall/selenium
  @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);
    }
  }
コード例 #5
0
ファイル: DragAndDropTest.java プロジェクト: epall/selenium
  @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
  }