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

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)

@mykola-mokhnach
Copy link

@anton-yereshchenko I have just merged #1016 to master

Please resolve conflicts and then we'd be ready to merge your PR

@anton-yereshchenko anton-yereshchenko force-pushed the features/add-real-frame-property branch from 06d7446 to 9cf76dc Compare May 21, 2025 12:14
@anton-yereshchenko
Copy link
Author

anton-yereshchenko commented May 21, 2025

@mykola-mokhnach I have resolved conflicts.
But I have filed tests that are related to 'one-time' app alerts, for example: 'testCameraRollAlert'. What is the best practice for it?
because locally it will work if I run it on a reset simulator.

@mykola-mokhnach
Copy link

@anton-yereshchenko please do not forget to update xcuitest documentation after this PR is merged and published.

@mykola-mokhnach mykola-mokhnach merged commit 09214c4 into appium:master May 21, 2025
40 of 42 checks passed
github-actions bot pushed a commit that referenced this pull request May 21, 2025
## [9.8.0](v9.7.1...v9.8.0) (2025-05-21)

### Features

* Add a native frame property of the element ([#1017](#1017)) ([09214c4](09214c4))
Copy link

🎉 This PR is included in version 9.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@KazuCocoa
Copy link
Member

Hi @anton-yereshchenko, congrats: the Appium project wants to compensate you for this contribution! Please reply to this comment mentioning @jlipps and @KazuCocoa and sharing your OpenCollective account name, so that we can initiate payment! Or let us know if you decline to receive compensation via OpenCollective. Thank you!

@anton-yereshchenko
Copy link
Author

@jlipps @KazuCocoa Wow, Thank you so much! Always happy to help.
Here is my OpenCollective account:
https://opencollective.com/anton-yereshchenko

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

Successfully merging this pull request may close these issues.

3 participants