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

[1.12] Add the ability to screenshot individual elements on the page #553

Merged
merged 9 commits into from
Nov 6, 2024

Conversation

osbre
Copy link
Contributor

@osbre osbre commented Oct 8, 2023

Note that currently, the position X and Y properties are not being recorded correctly because the type is int, while the original X and Y type can be float. This PR fixes it as well.

@osbre osbre force-pushed the feat/element-screenshots branch from 7dc110e to aea7f4d Compare October 8, 2023 14:36
@GrahamCampbell
Copy link
Member

This is probably still broken because width and height have to be ints, so you are just getting the top left corner position correct, but not the bottom right?

@GrahamCampbell
Copy link
Member

GrahamCampbell commented Oct 12, 2023

Are you able to test the change I pushed up work, please, and confirm that all 4 things are floats (and not just degenerate floats with a .0), passed through to chrome?

@osbre
Copy link
Contributor Author

osbre commented Oct 12, 2023

Tested, here is the data sample:

dd($element->getClip());
Clip (instance) {
  #x: 8.0
  #y: 79.875
  #height: 21.0
  #width: 784.0
  #scale: 1.0
}

Seems correct. (no fake floats)

Thanks!

@enricodias
Copy link
Member

That's a really simple but extremely useful feature 👍

@GrahamCampbell
Copy link
Member

The width and height look wrong. Surely those should also be fractional?

@osbre
Copy link
Contributor Author

osbre commented Nov 9, 2023

@GrahamCampbell Sorry for asking, but what do you mean by saying "fractional" in this context?

@GrahamCampbell
Copy link
Member

Fractional as in floats that are not ending in .0

@GrahamCampbell GrahamCampbell changed the title [1.10] Add the ability to screenshot individual elements on the page [1.11] Add the ability to screenshot individual elements on the page Dec 10, 2023
@GrahamCampbell GrahamCampbell changed the base branch from 1.10 to 1.11 December 10, 2023 02:28
@GrahamCampbell
Copy link
Member

Awaiting reply from @osbre.

@osbre
Copy link
Contributor Author

osbre commented Apr 17, 2024

@GrahamCampbell Did a test which confirmed that the width/height will be fractional if the element's width/height is explicitly set to a fractional number or is a percentage.

$page->navigate($this->sitePath('fractional.html'))->waitForNavigation();

$element = $page->dom()->querySelector('#fractional');
self::assertEquals(90.5, $element->getClip()->getWidth());
<html>
<body>
<p id="fractional" style="color: red; width: 90.5;">
    This element has a fractional width.
</p>
</body>
</html>

Should I make it a test and include it in this PR?

@GrahamCampbell GrahamCampbell changed the base branch from 1.11 to 1.12 November 6, 2024 09:48
@GrahamCampbell GrahamCampbell changed the title [1.11] Add the ability to screenshot individual elements on the page [1.12] Add the ability to screenshot individual elements on the page Nov 6, 2024
@GrahamCampbell GrahamCampbell merged commit e30b0bd into chrome-php:1.12 Nov 6, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants