Skip to content

feat: Add a real frame property of the element #1017

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 3 commits into
base: master
Choose a base branch
from

Conversation

anton-yereshchenko
Copy link

Summary

This pull request introduces support for retrieving the actual rendered frame of a UI element, providing a more precise representation than the standard wdFrame value.

Motivation

The original wdFrame property applies rounding logic, which in some cases may lead to inaccurate element sizes or positions.


Example Case: iPhone 16 Pro Simulator

Consider the following scenario:
We have a button, and after launching the app, we retrieve its frame using either a UI test or from within viewDidAppear.
The returned frame is:
(190.66666666666666, 426.6666666666667, 20.666666666666686, 20.66666666666663)

However, when requesting the same frame from WebDriverAgent (wdFrame), we receive:
(190, 426, 22, 22)

This difference - sometimes exceeding 1 pt and occasionally reaching 2 pt - can lead to inconsistencies, especially when performing 'pixel-perfect' validations.


Proposed Solution

We can round the frame values to two decimal places, resulting in a more accurate and human-readable format:
(190.67, 426.67, 20.67, 20.67)


Could we make some toggle in the configuration? To turn on this property?

Thanks for the idea with nonPrefixedKeys.
Ref: #1016

Copy link

linux-foundation-easycla bot commented May 16, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@anton-yereshchenko
Copy link
Author

@mykola-mokhnach Please take a look, when you have time.
Thank you!

@mykola-mokhnach mykola-mokhnach changed the title Add a real frame property of the element feat: Add a real frame property of the element May 16, 2025
//
// Use `wdRealFrameString` to obtain this value in a simplified string
// format, avoiding excessively long numeric values in the JSON output.
double factor = pow(10, 2);

Choose a reason for hiding this comment

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

I'm not sure if this conversation is really necessary. It's probably ok if we want to reduce json string size, but not ok if we just want to fetch the original native attribute value as is via the /attribute API

Copy link
Member

Choose a reason for hiding this comment

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

Agree. It makes sense for me to return the original one as-is for the original motivation (to return actual value as possible in terms of pixel perfect)

@anton-yereshchenko
Copy link
Author

Thank you @mykola-mokhnach and @KazuCocoa for your notes
Please check the updated version, when possible.
Thank you!

Copy link
Member

@KazuCocoa KazuCocoa left a comment

Choose a reason for hiding this comment

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

lgtm (running/re-running ci)

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