예제 #1
0
  @JavascriptEnabled
  @Test
  @Ignore(
      value = {SAFARI, MARIONETTE},
      reason = "Advanced mouse actions only implemented in rendered browsers",
      issues = {4136})
  @NotYetImplemented(HTMLUNIT)
  @NoDriverAfterTest
  public void testCanMoveOverAndOutOfAnElement() {
    driver.get(pages.mouseOverPage);

    WebElement greenbox = driver.findElement(By.id("greenbox"));
    WebElement redbox = driver.findElement(By.id("redbox"));
    Dimension size = redbox.getSize();

    new Actions(driver).moveToElement(greenbox, 1, 1).perform();

    assertEquals(
        Colors.GREEN.getColorValue(), Color.fromString(redbox.getCssValue("background-color")));

    new Actions(driver).moveToElement(redbox).perform();
    assertEquals(
        Colors.RED.getColorValue(), Color.fromString(redbox.getCssValue("background-color")));

    // IE8 (and *only* IE8) requires a move of 2 pixels. All other browsers
    // would be happy with 1.
    new Actions(driver).moveToElement(redbox, size.getWidth() + 2, size.getHeight() + 2).perform();
    assertEquals(
        Colors.GREEN.getColorValue(), Color.fromString(redbox.getCssValue("background-color")));
  }
예제 #2
0
  @JavascriptEnabled
  @Test
  @Ignore(
      value = {SAFARI, MARIONETTE},
      reason = "Advanced mouse actions only implemented in rendered browsers",
      issues = {4136})
  @NotYetImplemented(HTMLUNIT)
  // @NoDriverAfterTest
  public void testMoveMouseByOffsetOverAndOutOfAnElement() {
    driver.get(pages.mouseOverPage);

    WebElement greenbox = driver.findElement(By.id("greenbox"));
    WebElement redbox = driver.findElement(By.id("redbox"));
    Dimension size = redbox.getSize();
    Point greenboxPosition = greenbox.getLocation();
    Point redboxPosition = redbox.getLocation();
    int shiftX = redboxPosition.getX() - greenboxPosition.getX();
    int shiftY = redboxPosition.getY() - greenboxPosition.getY();

    new Actions(driver).moveToElement(greenbox, 2, 2).perform();

    assertEquals(
        Colors.GREEN.getColorValue(), Color.fromString(redbox.getCssValue("background-color")));

    new Actions(driver).moveToElement(greenbox, 2, 2).moveByOffset(shiftX, shiftY).perform();
    assertEquals(
        Colors.RED.getColorValue(), Color.fromString(redbox.getCssValue("background-color")));

    new Actions(driver)
        .moveToElement(greenbox, 2, 2)
        .moveByOffset(shiftX, shiftY)
        .moveByOffset(-shiftX, -shiftY)
        .perform();
    assertEquals(
        Colors.GREEN.getColorValue(), Color.fromString(redbox.getCssValue("background-color")));
  }