Repository navigation
feat(wda): an element check takes its fields from the find's answer - #263
Conversation
getElementInfo sent four requests after each find (GET /element/{id}/text,
/rect, /displayed and /name). WebDriverAgent answers them one at a time,
and each resolves the element again, so on a real iPhone a check cost the
find plus four round trips; on a long list a one-match check took about
2 s.
The session now asks WebDriverAgent to put those four fields in every
find's answer (shouldUseCompactResponses: false, elementResponseAttributes
"name,text,rect,displayed", sent with snapshotMaxDepth). They are the same
values the GETs return, read from the find's own snapshot
(FBDictionaryResponseWithElement). The finds that feed getElementInfo take
them from the answer and send no further request; when an answer lacks any
of them (a WebDriverAgent that ignored the settings), the four GETs run as
before. The id is read from ELEMENT or the W3C key and never from a field.
Refs devicelab-dev#258
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
I measured the many-matches case the description left open. Same iPhone 17 (iOS 27.0.1, WebDriverAgent 11.4.1), the Settings app's main screen, raw WDA calls, medians of three rounds in alternating order. "Before" is the compact find followed by this driver's reads (at most
The fields add nothing measurable to the find, even at 164 matches: the compact find alone took 16.4 s, and the find with the fields 15.3 s. WebDriverAgent takes each match's snapshot for its id anyway ( |
|
Thanks for this. Testing it for 1.1.31, I hit a regression on the simulator that I can't explain from the runner side, so I'm holding this PR until we understand it. What happens TestHive iOS login on WDA (iPhone 17 Pro simulator, iOS 27.0): tap the username field, type, then
What I tried First I thought only the rect in the find's answer was old, so I had the tap re-read the rect with On RNTester (48 flows, WDA) the results were the same with and without the PR, so I only see this on a screen whose layout moves after the find. Could you check on your devices whether |
|
Thanks for testing it. I checked your question on a real iPhone 17 (iOS 27.0.1, WebDriverAgent 11.4.1), with raw WDA calls on the Settings app, three rounds of each mode in alternating order: a session, the mode's settings, a find of the "General" row by accessibility id,
So on this device I could not reproduce the old position, so I can't explain what your simulator did. The one thing the PR changes in time: the tap now uses the rect from the find's own snapshot, where before it was read by four more requests, roughly 100-300 ms later on a simulator. If the form was still moving when the find ran, the PR's rect is where it was then, and the old |
Summary
Closes #258. An element check on the WDA driver sent the find and then four more requests (
GET /element/{id}/text,/rect,/displayedand/name). WebDriverAgent answers them one after another, and each resolves the element again. The session now asks WebDriverAgent to put those four fields in every find's answer, and the checks take them from there. On a real iPhone, a check by id on a busy page went from 7.4 s to 2.45 s.Type of Change
Changes Made
CreateSessionsendsshouldUseCompactResponses: falseandelementResponseAttributes: "name,text,rect,displayed"in the same/appium/settingscall assnapshotMaxDepth. WebDriverAgent ignores a setting it does not know.Client.FindElementWithFieldsandFindElementsWithFieldsreturn each element's id with its fields (Element,ElementFields), or with none when the answer lacks any of the four.FindElementandFindElementskeep their signatures for the other callers.ELEMENT, else from the first string value that is not a field. The W3C fallback took the first string value it met, which could now be the element'snameortext.getElementInfo(id)now callselementInfo(Element). With the fields it sends no request. Without them it reads them as before. The visibility rule after that is unchanged.findElementByWDA(a regex id, the text predicate),findByIDQueryandonScreenOf,findInteractiveElementByWDA, and the exact-text predicate infindElementForTapWithContext. Its contains-predicate fallback (step 4, after a page source) still reads the element again, since the page source came in between.element_fields_test.gowith a fake WDA, andTestCreateSession):TestFindAnswerFieldsSkipElementReads: by text and by id, no element GET when the answer has the fields, and the same type, text, bounds and visibility as the GETs would give;TestFindAnswerWithoutFieldsReadsThem: an answer without them, so the four GETs run;TestElementFromAnswer: the id from the W3C key and not from a field, a nulltextread as"", and no fields when the rect lacks a number;TestCreateSessionchecks that the two settings are sent.Related Issues
Closes #258
Testing
main:element_fields_test.godoes not compile there, andTestCreateSessionfails on the missing settingsgo vet,gofmt -s -land golangci-lint v2.13.2 (CI's pin, under go1.26.7) report nothinggo test -race ./...passes.pkg/driver/browser/cdpandpkg/emulatorwere left out: they fail on this Mac onmaintoo (Chrome's launch; an emulator holding 5554)--wda-url), the same build with and without this change, alternated over four rounds, medians:assertVisibleby id on an app's busy page (about 2,900 elements): 7.4 s → 2.45 s. The find took 1.9–3.0 s either way; the four reads were the rest;make testas a whole: not run, because its device tests drive whatever device is attachedChecklist
Additional Notes
nameiswdType, asGET /nameanswers.textis the value, else the label, asGET /text; it is null when both are empty, which is read as"", whatGET /textanswers then.rectiswdRect, anddisplayediswdVisible, asGET /displayed. They are read from the find's own snapshot (FBDictionaryResponseWithElementinFBResponsePayload.m). The code is the same in WebDriverAgent 11.4.1 and in the 16.17.5 this repository bundles.FBConfiguration), not per session. A later client of the same WebDriverAgent (--reuse-wda,--wda-url) gets the longer answers too. They still carryELEMENTand the W3C key, so a client that reads the id is not affected.onScreenOfread at mostmaxIDCandidates(5) elements, while a find with dozens of same-id matches now computes the fields for all of them. Measured since (comment): the fields add nothing measurable to the find, even at 164 matches.