browser: improve error wrapping for actionability functions#5610
Conversation
|
Items 1 (#5111 (comment)) and 6 (#5111 (comment)) were left out. 1 seems like an open question and 6 was noted for future backoff retry implementation. Happy to tackle either if needed. |
ankur22
left a comment
There was a problem hiding this comment.
@joaquinalmora thanks for contributing. I've lost all the context of the original issue and what feedback was given. To make it simpler to review i would really appreciate it if you could create a single commit per change linking back to the feedback comment.
Also, it looks like not all feedback is being incorporated into this PR (it says 2-5 in the PR description), can you clarify why that is? If might be necessary to leave the issue open if not all feedback is being taken care of in this PR.
|
@ankur22 Thanks for the feedback. |
Addresses feedback from grafana#5111 (comment) Signed-off-by: Joaquin Almora <jalmora@student.ubc.ca>
Addresses feedback from grafana#5111 (comment) Signed-off-by: Joaquin Almora <jalmora@student.ubc.ca>
Let clickablePoint() own its error message context. Addresses feedback from grafana#5111 (comment) Signed-off-by: Joaquin Almora <jalmora@student.ubc.ca>
Addresses feedback from grafana#5111 (comment) Signed-off-by: Joaquin Almora <jalmora@student.ubc.ca>
1726d8f to
045e838
Compare
ankur22
left a comment
There was a problem hiding this comment.
@joaquinalmora thanks for the clarification, i missed your earlier comment actually. I think the PR looks good.
- In terms of
nilrect or&rect{}, I think whatever matches the behaviour of Playwright. This is area under question:. Go ahead if you want to tackle that point.k6/internal/js/modules/k6/browser/browser/element_handle_mapping.go
Lines 18 to 24 in ecfb525
- I'm happy for you to attempt a backoff retry implementation. Also happy for you to not work on it. I personally feel that we should only really work on it if it becomes an issue.
|
@ankur22 I can tackle 1, going to hold off on 2. |
Signed-off-by: Joaquin Almora <jalmora@student.ubc.ca>
|
@ankur22 Fixed the inconsistency. locator.boundingBox() now returns nil for hidden elements to match Playwright behavior: https://playwright.dev/docs/api/class-elementhandle#element-handle-bounding-box |
73ee7ee to
33f342e
Compare
ankur22
left a comment
There was a problem hiding this comment.
Looks good. Left a comment to consider.
| if errors.Is(err, common.ErrElementNotVisible) { | ||
| return nil, nil | ||
| } |
There was a problem hiding this comment.
This change looks correct, but it doesn't match what the original feedback was: #5111 (comment), which was asking whether we should return a nail nil rect or an empty rect. I think returning a nil rect is good enough.
I'm happy to leave the change in though. I'm wondering if other boundingbox implementations need to this change too (I haven't checked myself whether that's the case yet though).
There was a problem hiding this comment.
Yea, the original feedback mentioned nil vs &Rect{} but after looking into Playwright's actual behavior, nil (returning null to JS) seemed like the correct choice. Looking at both JS-facing implementations they now behave the same: element_handle_mapping.go already had this check, and I just added it to locator_mapping.go. Those two are the only JS-facing ones I found.
There was a problem hiding this comment.
Nice one! Thanks for the clarification.
What
Improves error context in browser actionability functions by wrapping errors with descriptive messages for better debugging.
Why
Follow-up refactoring from #5111 addressing code review suggestions (items 2-5 from #5123).
Changes
clickablePoint(): Added"finding clickable point: %w"error wrappingoffsetPosition(): Added"finding offset position: %w"error wrappingnewPointerAction(): Changed to"pointer action: %w"(letclickablePoint()own its message)Frame.position(): Added"finding position in frame: %w"error wrappingChecklist
make check) and all pass.Closes #5123