fix(actions): unwrap aio element before resolving position - #27
Merged
Conversation
AsyncFirefoxElement (aio wrapper) does not expose _get_center, so Actions.human_move/_resolve_position silently fell back to the current pointer position when handed an async element, leaving the mouse unmoved. Unwrap the _sync element at the sync Actions boundary so all element-accepting actions (human_move/click/human_click/move_to/drag) work transparently with aio elements.
airqj
force-pushed
the
fix/actions-unwrap-aio-element
branch
from
August 2, 2026 07:46
1d333c0 to
4534485
Compare
LoseNine
approved these changes
Aug 3, 2026
LoseNine
left a comment
Owner
There was a problem hiding this comment.
Verified on Firefox 155.0a1: 456 fast tests, 52 targeted regressions, and 17 async browser tests passed.
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.
问题描述
aio API(
ruyipage[async],1.2.56)下,通过await page.ele(...)获取的AsyncFirefoxElement传入同步 Actions 链(human_move/click/human_click/move_to等)时,鼠标不会移动到元素位置,而是停留在当前坐标,且无任何报错。实际表现:对页面元素执行
human_move(btn)+perform()后 hover 未生效,随后按文本查找下拉项失败。最小复现
根本原因
同步
Actions依赖元素的_get_center()解析坐标,而 aio 包装元素AsyncFirefoxElement(ruyipage/_async/_generated.py)只生成公开方法,未暴露_get_center:ruyipage/_units/actions.pyhuman_move():is_element = hasattr(ele_or_loc, "states") and hasattr(ele_or_loc, "_get_center"),对 aio 元素恒为False;_resolve_position():get_center = getattr(ele_or_loc, "_get_center", None)取到None;return self.curr_x, self.curr_y—— 指针不移动,调用方无感知。修复方案
在同步 Actions 边界对 aio 包装元素解包(
AsyncFirefoxElement._sync指向其内部同步元素):human_move()入口解包一次,覆盖后续states可见性检查、scroll.to_see、_resolve_position;_resolve_position()入口解包一次,覆盖click/human_click/move_to/drag_to等所有经坐标解析的调用链。对 dict / tuple / None 入参无影响(解包仅作用于含
_sync属性的对象)。测试
tests/test_actions_drag_staging.py3 passed验证说明
本修复已在调用方项目实测:aio 页面下对"筛选"按钮
human_move后下拉框正常展开,元素可被定位。