Repository navigation
Conversation
… source dictionaryForElement: set customActions outside the attribute block map, so excluded_attributes could not drop it and wdCustomActions was read for every element. Move it into the block map as a non-prefixed key, like nativeFrame and minValue/maxValue. The default JSON output is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
excluded_attributescannot dropcustomActionsfrom the JSON page source (/source?format=json).dictionaryForElement:setscustomActionsnext toname,value,labelandrect, outside the attribute block map that the exclusion loop reads, sowdCustomActionsis read for every element regardless ofexcluded_attributes.This PR moves
customActionsinto that block map as a non-prefixed key, likenativeFrame,minValueandmaxValue. Withexcluded_attributes=customActions,wdCustomActionsis not called and the key is absent. Requests that do not exclude it get the same output as before: every node hascustomActions, withnullwhen the getter returnsnil. The accessibility audit callsdictionaryForElement:with onlyvisibleandaccessibleexcluded, so itselementAttributesstill includecustomActions.Why
fb_customActionsasks accessibility forXC_kAXXCAttributeCustomActions. For an element without custom actions it logs[FBCustomActions] Cannot determine string value for XC_kAXXCAttributeCustomActions: (null). A failed request logs the same line with the accessibility error (for examplekAXErrorInvalidUIElement), and an array of actions logs one[FBCustomActions] Custom action title: …line per action. On our iPhone 15 runner (WDA 16.15.3, which has the same custom actions code asmain, polled with/source?format=json),[FBCustomActions]lines were 1,116,971 of 1,403,311 log lines (80%) between Oct 18 and Oct 26.type,rawIdentifier,name,value,label,rectandcustomActionscan already be excluded (frame,nativeFrame,enabled,visible,accessible,nativeAccessibilityElement,focused,traits,placeholderValue,minValue,maxValue).pageSourceExcludedAttributesasexcluded_attributeswithuseJSONSourcetoo (lib/commands/source.ts), so its users can setpageSourceExcludedAttributes=customActionsafter this change. WithuseJSONSourcethe driver'sgetTreeForXMLkeeps onlytype,enabled,visible,accessible,focused,rect,name,labelandvalue, so todaycustomActionsis fetched for every node but never reaches the driver's XML.I did not make the JSON tree follow
includeCustomActionsInPageSource, which the XML source uses, because that would drop the key from the default JSON output.nativeFrame,nativeAccessibilityElement,minValueandmaxValuealready work this way: they are in the default JSON output and can be excluded there, while XML includes them only withincludeNativeFrameInPageSource,includeNativeAccessibilityElementInPageSourceandincludeMinMaxValueInPageSource(for examplenativeAccessibilityElementin appium/WebDriverAgent#1146). If you prefer to gate the JSON output with the setting instead, I can change the PR.Tests
New integration test
FBElementAttributeTests/testCustomActionsInJSONTree. In the default tree every node has acustomActionskey and the button hasCustom Action 1,Custom Action 2. WithcustomActionsexcluded, no node has the key. Onmainthe last check fails: 41 nodes still have the key.On an iPhone 17 simulator (iOS 27.0, Xcode 27.1):
UnitTests: 186 tests, 0 failures.IntegrationTests_1/FBElementAttributeTests: 19 tests, 0 failures, 1 skipped. The skipped test istestIgnoredAccessibilityAttributes("No image element available to test"), which does not read the JSON tree.IntegrationTests_2/XCUIApplicationHelperTeststestApplicationTree,testApplicationTreeAttributesFilteringandtestAccessbilityAudit: 3 tests, 0 failures.Timing
Settings app root screen (167 nodes) on the same simulator. With this PR,
excluded_attributes=customActionscut the median request time from 1.338 s to 0.964 s in round 1 and from 1.150 s to 0.972 s in round 2, and the[FBCustomActions]lines per request from 167 to 0. Onmainthe parameter has no effect: all 167 nodes keep the key and each request logs 167 lines.Method and all numbers
Each build ran in one runner process: one warm-up request, then two rounds. Each round sent 20 plain
GET /session/:id/source?format=jsonrequests, then 20 withexcluded_attributes=customActions.customActions(plain / excluded)[FBCustomActions]lines per request (plain / excluded)mainmainThe runs were noisy. Medians moved by up to 0.19 s between rounds of the same build and request, and the two builds ran at different times, so compare the two cells within a row rather than across builds. A plain request calls the same getters in both builds. The minimums show the same as the medians: 1.188 → 0.931 s and 1.079 → 0.900 s with this PR, 1.036 → 1.030 s and 1.053 → 1.053 s on
main.Docs
After this is merged I will open a PR in appium-xcuitest-driver to update the
pageSourceExcludedAttributesdocs. They say that withuseJSONSourceonlyframe,enabled,visible,accessibleandfocusedare supported, so I will addcustomActionsand the other attributes the JSON source can exclude.🤖 Generated with Claude Code