Package org.openqa.selenium

Examples of org.openqa.selenium.Point


    return StringUtils.EMPTY;
  }

  public Point getLocation() {
    if(is_not_null(_webElement)) {
      Point value = _webElement.getLocation();
      info("Element '" + this.name() + "' - Location is '" + value + "'");
      return value;
    } else {
      info("Element '" + this.name() + "' - has a null _webelement, cannot do getLocation()");
    }
    return new Point(0, 0);
  }
View Full Code Here


    }
  }

  private CandidateElementPosition findElement(WebElement webElement,
          CandidateElement element) {
    Point location = webElement.getLocation();
    Dimension size = webElement.getSize();
    CandidateElementPosition renderedCandidateElement =
            new CandidateElementPosition(element.getIdentification().getValue(),
                    location, size);
    if (location.getY() < 0) {
      LOG.warn("Weird positioning {} for {}", webElement.getLocation(),
              renderedCandidateElement.getXpath());
    }
    return renderedCandidateElement;
  }
View Full Code Here

    return this;
  }
 
  public String static_info() {
    String info = "";
    Point point = getLocation();
    info += "X = " + point.getX();
    info += ", Y = " + point.getY();
    Dimension dimension = getSize();
    info += ", Height = " + dimension.getHeight();
    info += ", Width = " + dimension.getWidth();
    return info;
  }
View Full Code Here

//    return elements;
//  }
 
  public void move_by(int x, int y) {
    takeScreenshot();
    Point current_location = getLocation();
    action("Current position of element '" + current_location + "', Moving by (x, y) = (" + x + ", " + y + ")");
   
    Actions drag = new Actions(browser.driver());
    try {
      drag.dragAndDropBy(_nativeWebElement(), x, y).build().perform();
      Point new_location = getLocation();
      action("New position of element '" + new_location + "', Moved by (x, y) = (" + x + ", " + y + ")");
    } catch (org.openqa.selenium.interactions.MoveTargetOutOfBoundsException mtoobe) {
      error("Cannot move element '" + current_location + "', to (x, y) = (" + x + ", " + y + "), got org.openqa.selenium.interactions.MoveTargetOutOfBoundsException");
    }
   
View Full Code Here

    takeScreenshot();
  }
 
  public void move_to(int x, int y) {
    takeScreenshot();
    Point current_location = getLocation();
    int offset_x = x - current_location.getX();
    int offset_y = y - current_location.getY();
   
    action("Current position of element '" + current_location + "', Moving to (x, y) = (" + x + ", " + y + ")");
    Actions drag = new Actions(browser.driver());
    try {
      drag.dragAndDropBy(_nativeWebElement(), offset_x, offset_y).build().perform();
      Point new_location = getLocation();
      action("New position of element '" + new_location + "', Moved to (x, y) = (" + x + ", " + y + ")");
    } catch (org.openqa.selenium.interactions.MoveTargetOutOfBoundsException mtoobe) {
      error("Cannot move element '" + current_location + "', to (x, y) = (" + x + ", " + y + "), got org.openqa.selenium.interactions.MoveTargetOutOfBoundsException");
    }
   
View Full Code Here

        FluentWebElement fwe = fwd.div();

        assertThat(fwe, notNullValue());

        when(we.getLocation()).thenReturn(new Point(1, 1));
        TestableValue<Point> location = fwe.getLocation();
        TestableValue<Point> pointShouldOrShouldNotBeMatchable = location.shouldBe(new Point(1, 1));
        Point locn = pointShouldOrShouldNotBeMatchable.value();
        assertThat(locn.toString(), equalTo("(1, 1)"));

        when(we.getLocation()).thenReturn(new Point(1, 1));
        try {
            fwe.getLocation().shouldBe(new Point(2, 2)).value();
            fail("should have barfed");
        } catch (FluentExecutionStopped e) {
            assertThat(e.getMessage(), equalTo("AssertionError during invocation of: ?.div().getLocation().shouldBe('(2, 2)')"));
            assertThat(e.getCause().getMessage().replace("(after 1 ms)", ""), equalTo("\nExpected: <(2, 2)>\n     but: was <(1, 1)>"));
        }

        when(we.getLocation()).thenReturn(new Point(1, 1));
        locn = fwe.getLocation().shouldNotBe(new Point(2, 2)).value();
        assertThat(locn.toString(), equalTo("(1, 1)"));

        when(we.getLocation()).thenReturn(new Point(1, 1));
        try {
            fwe.getLocation().shouldNotBe(new Point(1, 1)).value();
            fail("should have barfed");
        } catch (FluentExecutionStopped e) {
            assertThat(e.getMessage(), equalTo("AssertionError during invocation of: ?.div().getLocation().shouldNotBe('(1, 1)')"));
            assertThat(e.getCause().getMessage().replace("(after 1 ms)", ""), equalTo("\nExpected: not <(1, 1)>\n     but: was <(1, 1)>"));
        }
View Full Code Here

    String solved = null;
    try {           
            solver = CaptchaSolverFactory.createSolver(properties);
            img = ((ICaptcha)app).getCaptchaImage();
      File screenshot = ((TakesScreenshot)app.getWebDriver()).getScreenshotAs(OutputType.FILE);
      Point point = img.getLocation();
      int eleWidth = img.getSize().getWidth();
      int eleHeight = img.getSize().getHeight();
      BufferedImage  fullImg = ImageIO.read(screenshot);
      //Crop the entire page screenshot to get only element screenshot
      BufferedImage eleScreenshot= fullImg.getSubimage(point.getX(), point.getY(), eleWidth, eleHeight);
      ImageIO.write(eleScreenshot, "png", screenshot);
      FileUtils.copyFile(screenshot, new File("lastcaptcha.png"));
      solved = solver.solve(screenshot);
      if (solved != null) {
        log.debug("Solved CAPTCHA as: "+solved);
View Full Code Here

        return new Dimension(0,0);
    }

    @Override
    public Point getPosition() {
        return new Point(0,0);
    }
View Full Code Here

        d.get("http://www.google.com");
        assertTrue(d.manage().window().getPosition().x >= 0);
        assertTrue(d.manage().window().getPosition().y >= 0);

        d.manage().window().setPosition(new Point(0, 0));
        assertTrue(d.manage().window().getPosition().x == 0);
        assertTrue(d.manage().window().getPosition().y == 0);
    }
View Full Code Here

   * NOTE: This method is still under development.
   * @return
   */
  public String static_info() {
    String info = "";
    Point point = getLocation();
    info += "X = " + point.getX();
    info += ", Y = " + point.getY();
    Dimension dimension = getSize();
    info += ", Height = " + dimension.getHeight();
    info += ", Width = " + dimension.getWidth();
    return info;
  }
View Full Code Here

TOP

Related Classes of org.openqa.selenium.Point

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.