-
Notifications
You must be signed in to change notification settings - Fork 450
feat: Add new Appium setting for in-depth snapshot in JSON page source #997
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
feat: Add new Appium setting for in-depth snapshot in JSON page source #997
Conversation
The committers listed above are authorized under a signed CLA. |
| - (NSDictionary *)fb_tree:(nullable NSSet<NSString *> *)excludedAttributes | ||
| { | ||
| id<FBXCElementSnapshot> snapshot = [self fb_takeSnapshot:YES]; | ||
| id<FBXCElementSnapshot> snapshot = [self fb_takeSnapshot:[FBConfiguration inDepthSnapshot]]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how this is supposed to work. setting this argument to NO makes the snapshotting function to not return the children property, which renders the recursive tree fetching impossible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mykola-mokhnach
The fb_takeSnapshot function allows passing inDepth: NO.
[self snapshotWithError:&error]According to the official documentation, this method retrieves the entire hierarchy, including child elements.
I compared the results of passing YES and NO to inDepth, and both responses appear identical.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps this trick only works for root/application elements. Let me test it locally.
Could you also provide performance comparison results?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mykola-mokhnach
Is time comparison metrics enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mykola-mokhnach
💡 Performance Summary:
With visible attribute (default):
inDepth=true: ~15s
inDepth=false: ~11s
With visible attribute excluded (appiumpageSourceExcludedAttributes: "visible"):
inDepth=true: ~3s (5× faster)
inDepth=false: ~0.5s (22× faster)
Yes, performance varies depending on the screen complexity. Using inDepth=false with excluded visible attributes can bring the page source API response time down to under 1 second in most cases.
The main motivation for this optimization in WebDriverAgent is to support a new library for the Appium ecosystem that will provide more generic element finding capabilities. This library will use element coordinate information (x,y bounds) to implement relative positioning strategies like "left of text", "right of text", "below", "above", etc.
We can make these spatial element-finding strategies much more efficient by improving the page source retrieval performance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say in case this snapshotting strategy really improves the performance then there is no point in putting it under a flag. Lets make it the default setting instead. @vinaykumar0339 Please check if #998 works for you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mykola-mokhnach Yes, this change (#998) works for me as well since it uses:
[self snapshotWithError:&error]May I ask when this change could be pushed along with Appium? (https://github.com/appium/appium-xcuitest-driver/)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Published in the xcuitest driver 9.1.3+
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mykola-mokhnach for the quick response and for considering my suggestion! Appreciate the effort in creating a new version based on it. 🚀
This PR introduces a new inDepthSnapshot flag that provides flexibility in retrieving the iOS UI hierarchy faster.
inDepthSnapshotallows users to control whether to take an in-depth snapshot or a faster, lightweight snapshot.How to use it
