org.openqa.selenium.Point.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(161)

本文整理了Java中org.openqa.selenium.Point.<init>()方法的一些代码示例,展示了Point.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Point.<init>()方法的具体详情如下:
包路径:org.openqa.selenium.Point
类名称:Point
方法名:<init>

Point.<init>介绍

暂无

代码示例

代码示例来源:origin: selenide/selenide

WebDriver adjustBrowserPosition(Config config, WebDriver driver) {
 if (config.browserPosition() != null) {
  log.info("Set browser position to " + config.browserPosition());
  String[] coordinates = config.browserPosition().split("x");
  int x = Integer.parseInt(coordinates[0]);
  int y = Integer.parseInt(coordinates[1]);
  Point target = new Point(x, y);
  Point current = driver.manage().window().getPosition();
  if (!current.equals(target)) {
   driver.manage().window().setPosition(target);
  }
 }
 return driver;
}

代码示例来源:origin: appium/java-client

/**
 * It defines x and y coordinates.
 * This is offset from the upper left corner of the screen.
 *
 * @param xOffset is x value.
 * @param yOffset is y value.
 * @return self-reference
 */
public T withCoordinates(int xOffset, int yOffset) {
  coordinates = new Point(xOffset, yOffset);
  //noinspection unchecked
  return (T) this;
}

代码示例来源:origin: appium/java-client

/**
   * Transforms a map into {@link Point} object.
   *
   * @param map the source map.
   * @return {@link Point} object
   */
  public static Point mapToPoint(Map<String, Object> map) {
    return new Point(toSeleniumCoordinate(map.get("x")), toSeleniumCoordinate(map.get("y")));
  }
}

代码示例来源:origin: appium/java-client

/**
 * Method returns central coordinates of an element.
 * @return The instance of the {@link org.openqa.selenium.Point}
 */
public Point getCenter() {
  Point upperLeft = this.getLocation();
  Dimension dimensions = this.getSize();
  return new Point(upperLeft.getX() + dimensions.getWidth() / 2,
    upperLeft.getY() + dimensions.getHeight() / 2);
}

代码示例来源:origin: appium/java-client

@Test
public void tapOptionsShouldBuildProperly() {
  final Map<String, Object> actualOpts = tapOptions()
      .withPosition(point(new Point(0, 0)))
      .withTapsCount(2)
      .build();
  final Map<String, Object> expectedOpts = new HashMap<>();
  expectedOpts.put("x", 0);
  expectedOpts.put("y", 0);
  expectedOpts.put("count", 2);
  assertThat(actualOpts.entrySet(), everyItem(isIn(expectedOpts.entrySet())));
  assertThat(expectedOpts.entrySet(), everyItem(isIn(actualOpts.entrySet())));
}

代码示例来源:origin: appium/java-client

@Test
public void invalidOptionsArgumentsShouldFailOnAltering() {
  final List<Runnable> invalidOptions = new ArrayList<>();
  invalidOptions.add(() -> waitOptions(ofMillis(-1)));
  invalidOptions.add(() -> new ElementOption().withCoordinates(new Point(0, 0)).withElement(null));
  invalidOptions.add(() -> new WaitOptions().withDuration(null));
  invalidOptions.add(() -> tapOptions().withTapsCount(-1));
  invalidOptions.add(() -> longPressOptions().withDuration(null));
  invalidOptions.add(() -> longPressOptions().withDuration(ofMillis(-1)));
  for (Runnable item : invalidOptions) {
    assertThat(item, failsWith(RuntimeException.class));
  }
}

代码示例来源:origin: com.atlassian.confluence/confluence-webdriver-pageobjects

private Point getCoordForColRow(int col, int row) {
    int adjustLeft = CELL_WIDTH / 2;
    int adjustTop = CELL_HEIGHT / 2;

    int destinationY = (row * CELL_HEIGHT) - adjustTop;
    int destinationX = (col * CELL_WIDTH) - adjustLeft;

    return new Point(destinationX, destinationY);
  }
}

代码示例来源:origin: appium/java-client

window.setSize(d);
Point p = new Point(50, 50);
window.setPosition(p);

代码示例来源:origin: com.atlassian.selenium/atlassian-webdriver-core

private void calculateCoordinates()
  {
    int relativeX = x - scrollTo.getX();
    int relativeY = y - scrollTo.getY();
    elementCoordinates = new Point(relativeX, relativeY);
  }
}

代码示例来源:origin: com.atlassian.selenium/atlassian-webdriver-core

private void calculateScroll()
{
  int deltaX = Math.max(0, document.getWidth() - viewport.getWidth());
  int scrollX = Math.min(x, deltaX);
  int deltaY = Math.max(0, document.getHeight() - viewport.getHeight());
  int scrollY = Math.min(y, deltaY);
  scrollTo = new Point(scrollX, scrollY);
}

代码示例来源:origin: com.opera/operadriver

public void mouseMove(Coordinates where, long xOffset, long yOffset) {
 Point p = getPoint(where, "mouse move");
 // We can't compare against Integer.MAX_VALUE and throw because this method isn't defined as
 // able to throw an Exception.  Weird things will just happen here...
 int xO = (int) xOffset;
 int yO = (int) yOffset;
 lastMousePosition = new Point(p.x + xO, p.y + yO);
 exec.mouseAction(p.x + xO, p.y + yO);
}

代码示例来源:origin: com.infotel.seleniumRobot/core

public CachedHtmlElement(Element jsoupElement) {
  location = new Point(0, 0);
  size = new Dimension(0, 0);
  rectangle = new Rectangle(location, size);
  selected = false;
  cachedElement = jsoupElement;
  realElement = null;
}

代码示例来源:origin: org.seleniumhq.selenium/selenium-htmlunit-driver

@Override
public Point getLocation() {
 assertElementNotStale();
 try {
  return new Point(readAndRound("left"), readAndRound("top"));
 } catch (Exception e) {
  throw new WebDriverException("Cannot determine size of element", e);
 }
}

代码示例来源:origin: paypal/SeLion

@Override
public void swipeLeft(WebElement webElement) {
  logger.entering(webElement);
  Point point = webElement.getLocation();
  Dimension dimension = webElement.getSize();
  Point start = new Point(point.getX() + dimension.getWidth() - 1, point.getY());
  Point end = new Point(point.getX(), point.getY());
  performSwipeAction(start, end);
  logger.exiting();
}

代码示例来源:origin: paypal/SeLion

@Override
public void swipeRight(WebElement webElement) {
  logger.entering(webElement);
  Point point = webElement.getLocation();
  Dimension dimension = webElement.getSize();
  Point start = new Point(point.getX(), point.getY());
  Point end = new Point(point.getX() + dimension.getWidth() - 1, point.getY());
  performSwipeAction(start, end);
  logger.exiting();
}

代码示例来源:origin: paypal/SeLion

@Override
public void swipeUp(WebElement webElement) {
  logger.entering(webElement);
  Point point = webElement.getLocation();
  Dimension dimension = webElement.getSize();
  Point start = new Point(point.getX(), point.getY() + dimension.getHeight() - 1);
  Point end = new Point(point.getX(), point.getY());
  performSwipeAction(start, end);
  logger.exiting();
}

代码示例来源:origin: net.serenity-bdd/core

protected void resizeBrowserTo(WebDriver driver, int height, int width) {
  LOGGER.info("Setting browser dimensions to {}/{}", height, width);
  driver.manage().window().setSize(new Dimension(width, height));
  driver.manage().window().setPosition(new Point(0,0));
}

代码示例来源:origin: io.appium/java-client

/**
 * Method returns central coordinates of an element.
 * @return The instance of the {@link org.openqa.selenium.Point}
 */
public Point getCenter() {
  Point upperLeft = this.getLocation();
  Dimension dimensions = this.getSize();
  return new Point(upperLeft.getX() + dimensions.getWidth() / 2,
    upperLeft.getY() + dimensions.getHeight() / 2);
}

代码示例来源:origin: net.serenity-bdd/serenity-core

@Override
  public void redimension(WebDriver driver) {
    try {
      driver.manage().window().setSize(new Dimension(width, height));
      driver.manage().window().setPosition(new Point(0, 0));
    } catch (WebDriverException couldNotResizeScreen) {
      if (couldNotResizeScreen.getMessage().contains("Invalid requested size")) {
        driver.manage().window().maximize();
      }
    }
  }
}

代码示例来源:origin: com.atlassian.selenium/atlassian-webdriver-core

private void setSize(Dimension dimension)
{
  support.getDriver().manage().window().setPosition(new Point(0,0));
  support.getDriver().manage().window().setSize(dimension);
  // _not_ a mistake... don't ask
  support.getDriver().manage().window().setSize(dimension);
}

相关文章