Skip to content

[Java] FPS support for local grid using bidi #236

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

omacranger
Copy link
Member

Description

Adds support for Full Page Screenshots using BiDi on a local selenium instance. Requires use of a webSocketUrl: true capability in order to be functional.

Types of Changes

  • New feature (non-breaking change which adds functionality)
  • Refactor/improvements

@@ -57,7 +57,7 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.10.0</version>
<version>4.32.0</version>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is breaking, as newer versions of Selenium (4.12+ IIRC) have dropped support for Java 8 so our build step will fail.

@@ -728,6 +743,18 @@ private String sauceVisualCheckLocal(String snapshotName, CheckOptions options)
return result.result.getId();
}

private byte[] getScreenshot(boolean fullPage) {
if (fullPage) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested it across all major browsers and with various websites?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BiDi is not currently supported in Safari, but it depends on our target use case whether that might be okay. Otherwise, Diego said this works across Firefox and chromium based browsers.

Logan Graham added 2 commits May 15, 2025 17:38
refactor cropping feature to support local fps
Comment on lines +641 to +646
clipRect =
new Rectangle(
(int) Math.round(clipElementDims.getX() * devicePixelRatio),
(int) Math.round(clipElementDims.getY() * devicePixelRatio),
(int) Math.round(clipElementDims.getHeight() * devicePixelRatio),
(int) Math.round(clipElementDims.getWidth() * devicePixelRatio));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this should belong in a helper of some sort, or at least a function in this class.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what reason? It's only 4 lines, and those lines are pretty readable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess... it's just that this function is growing very quickly.

WebElement clipElement = getClipElement(options);
Point scrollOffset = fullPage ? new Point(0, 0) : window.getViewport().getPoint();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to set scrollOffset to window.getViewport().getPoint() if clipElement == null (i.e. as an else statement after if (clipElement != null))? I think it is always overriden if clipElement is not null.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that'd be necessary since the default is set here (and we'd just be overriding it in the else).

And that's correct on clip front -- at least for non full page screenshots. We will always attempt to scroll the element into view so we update the position here after that call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants