mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-02 04:12:45 +02:00
Merge branch 'fixbug/browser_click_fail' into 'mgx_ops'
解决了playwright无法点击可见域外元素的问题 See merge request pub/MetaGPT!334
This commit is contained in:
commit
fedc771478
1 changed files with 6 additions and 0 deletions
|
|
@ -111,6 +111,12 @@ async def click_element(page: Page, backend_node_id: int):
|
|||
resp = await get_bounding_rect(cdp_session, backend_node_id)
|
||||
node_info = resp["result"]["value"]
|
||||
x, y = await get_element_center(node_info)
|
||||
# Move to the location of the element
|
||||
await page.evaluate(f"window.scrollTo({x}- window.innerWidth/2,{y} - window.innerHeight/2);")
|
||||
# Refresh the relative location of the element
|
||||
resp = await get_bounding_rect(cdp_session, backend_node_id)
|
||||
node_info = resp["result"]["value"]
|
||||
x, y = await get_element_center(node_info)
|
||||
await page.mouse.click(x, y)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue