Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question: why using JS execution to pull location & dimension of an element #7

Closed
BogdanLivadariu opened this issue Oct 7, 2016 · 1 comment

Comments

@BogdanLivadariu
Copy link

BogdanLivadariu commented Oct 7, 2016

regarding the implementation from here

why do you use "hard-core" JS execution, when you could simply pull the information directly from the WebElement?

WebElement el;
el.getLocation(); // returns a Point
el.getSize(); // returns a Dimension

    public Coordinates getBoundingClientRect(WebElement element) {
        return new Coordinates(element.getLocation(), element.getSize());
    }
@inha-briia
Copy link
Member

inha-briia commented Oct 9, 2016

Hi @BogdanLivadariu,

Yes, you are right. We could have used el.getSize(); here.

Its more tricky with el.getLocation(); though, it returns absolute coordinated of an element on the page, while using JS element.getBoundingClientRect(); returns location relatively to the view port.

Since the current version of Shutterbug does not support making screenshot of an element which is outside of the view port, we need to locate the element using relative coordinates.

We are planning to add the feature of screenshotting the element which is located outside the view port in the next release and so use the code you have suggested.

Thanks,
Inha

@glibas glibas closed this as completed Oct 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Shutterbug
  
Done
Development

No branches or pull requests

3 participants