Package org.openqa.selenium

Examples of org.openqa.selenium.Point


     * @return true if the element is in the window's viewport, i.e. is scrolled to; false otherwise.
     * @since 6.2
     */
    public boolean isElementInView(By elementLocator)
    {
        Point elementLocation = getDriver().findElement(elementLocator).getLocation();

        int windowXLeft = Integer.parseInt(getSelenium().getEval("window.scrollX"));
        int windowYTop = Integer.parseInt(getSelenium().getEval("window.scrollY"));

        int width = Integer.parseInt(getSelenium().getEval("document.documentElement.clientWidth"));
        int height = Integer.parseInt(getSelenium().getEval("document.documentElement.clientHeight"));

        int windowXRight = windowXLeft + width;
        int windowYBottom = windowYTop + height;

        return (elementLocation.getX() >= windowXLeft && elementLocation.getX() <= windowXRight
            && elementLocation.getY() >= windowYTop && elementLocation.getY() <= windowYBottom);
    }
View Full Code Here


    /**
     * Workaround for Drag and Drop
     */
    private void dragAndDropAction(WithOffset offset, Actions builder, WebElement source, WebElement target) {
        Point sourceLocation = source.getLocation();
        Point targetLocation = target.getLocation();
        int x = targetLocation.getX() - sourceLocation.getX() + offset.getOffset();
        int y = targetLocation.getY() - sourceLocation.getY() + offset.getOffset();
        builder.dragAndDropBy(source, x, y);
//            builder.clickAndHold(source);
//            builder.moveToElement(target);
//            builder.moveByOffset(offset.getOffset(),offset.getOffset());//second move will throw exception
//            builder.release();
View Full Code Here

    assertThat(deserialized, is(model));
  }

  private OutPutModel createModel() throws IOException {
    ImmutableList<CandidateElementPosition> candidateElements =
            ImmutableList.of(new CandidateElementPosition("a/b/c", new Point(1, 2),
                    new Dimension(3, 4)));
    State state1 =
            new State("state1", "http://example.com/a", candidateElements, 1, 1, 1,
                    ImmutableList.of("failedEvent1"));
    State state2 =
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

    State state = result.getStates().get("index");
    assertThat(state, is(notNullValue()));
    List<CandidateElementPosition> candidates = state.getCandidateElements();
    assertThat("Number of hovers", candidates, hasSize(3));
    Assume.assumeTrue(resolutionBigEnough);
    assertThat(candidates, hasItem(element(new Point(48, 118), new Dimension(52, 16))));
    assertThat(candidates, hasItem(element(new Point(48, 137), new Dimension(51, 16))));
    assertThat(candidates, hasItem(element(new Point(48, 156), new Dimension(200, 16))));
  }
View Full Code Here

    State state = getStateByFileName("a.html");
    assertThat(state, is(notNullValue()));
    List<CandidateElementPosition> candidates = state.getCandidateElements();
    assertThat(candidates, hasSize(1));
    Assume.assumeTrue(resolutionBigEnough);
    assertThat(candidates, hasItem(element(new Point(58, 147), new Dimension(89, 16))));
  }
View Full Code Here

    State state = getStateByFileName("b.html");
    assertThat(state, is(notNullValue()));
    List<CandidateElementPosition> candidates = state.getCandidateElements();
    assertThat(candidates, hasSize(1));
    Assume.assumeTrue(resolutionBigEnough);
    assertThat(candidates, hasItem(element(new Point(60, 168), new Dimension(51, 16))));
  }
View Full Code Here

    private File overlayWebElementBorders(List<WebElement> elements, File screenShotFile) throws IOException {
        BufferedImage image = ImageIO.read(screenShotFile);
        Graphics2D graphics = image.createGraphics();

        for (WebElement element : elements) {
            Point elementTopLeft = LocationFinder.getLocation(element);
            if (LocationFinder.isMobile(element)) {
                elementTopLeft = padLocationToAccountForScrolling(elementTopLeft);
            }
            org.openqa.selenium.Dimension elementSize = element.getSize();
            createHighlightAroundElement(graphics, elementTopLeft, elementSize);
View Full Code Here

            scrollHeight = ((Long) pageYOffset).intValue();
        } catch (Exception e) {
            System.out.println("Error" + e);
        }

        return new Point(elementTopLeft.getX(), elementTopLeft.getY() + scrollHeight);
    }
View Full Code Here

    public void createAndSaveThumbnail(File file, WebElement element) {
        createAndSaveThumbnail(file, 0, element);
    }

    public void createAndSaveThumbnail(File file, int index, WebElement element) {
        Point centerPoint = getCenter(element);
        Dimension elementDimension = element.getSize();
        BufferedImage image = loadImage(file);
        if (centerPoint != null) {
            Point cropPoint = findImageCropPoint(centerPoint, image);
            int cropWidth = thumbnailWidth;
            int cropHeight = thumbnailHeight;

            if (elementDimension.getWidth() > thumbnailWidth) {
                int newXPoint = cropPoint.getX() - (elementDimension.getWidth() / 2);
                if (newXPoint < 0) {
                    newXPoint = 0;
                }
                cropPoint = new Point(newXPoint, cropPoint.getY());
            }

            if (image.getHeight() < thumbnailHeight) {
                cropHeight = image.getHeight();
            }

            if (image.getWidth() < thumbnailWidth) {
                cropWidth = image.getWidth();
            }

            image = crop(image, cropPoint.getX(), cropPoint.getY(), cropWidth, cropHeight);
        } else {

            if ((image.getHeight() > thumbnailHeight) || (image.getWidth() > thumbnailWidth)) {
                image = resize(image, thumbnailWidth);
            }
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.