コード例 #1
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());
 }
コード例 #2
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());
 }
コード例 #3
0
  @JavascriptEnabled
  @Ignore("htmlunit, safari")
  public void testShouldAllowInheritedStylesToBeUsed() {
    driver.get(javascriptPage);

    RenderedWebElement element = (RenderedWebElement) driver.findElement(By.id("green-item"));
    String backgroundColour = element.getValueOfCssProperty("background-color");

    assertEquals("transparent", backgroundColour);
  }
コード例 #4
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
  }
コード例 #5
0
  @JavascriptEnabled
  @Ignore("htmlunit, safari")
  public void testShouldPickUpStyleOfAnElement() {
    driver.get(javascriptPage);

    RenderedWebElement element = (RenderedWebElement) driver.findElement(By.id("green-parent"));
    String backgroundColour = element.getValueOfCssProperty("background-color");

    assertEquals("#008000", backgroundColour);

    element = (RenderedWebElement) driver.findElement(By.id("red-item"));
    backgroundColour = element.getValueOfCssProperty("background-color");

    assertEquals("#ff0000", backgroundColour);
  }
コード例 #6
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);
    }
  }
コード例 #7
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());
 }
コード例 #8
0
ファイル: DragAndDropTest.java プロジェクト: epall/selenium
 private void drag(
     RenderedWebElement elem, Point expectedLocation, int moveRightBy, int moveDownBy) {
   elem.dragAndDropBy(moveRightBy, moveDownBy);
   expectedLocation.move(expectedLocation.x + moveRightBy, expectedLocation.y + moveDownBy);
 }