MCPcopy Create free account
hub / github.com/THUDM/AutoWebGLM / aexecute_action

Function aexecute_action

webarena/browser_env/actions.py:1390–1517  ·  view source on GitHub ↗

Execute the async action on the ChromeDriver.

(
    action: Action, page: APage, browser_ctx: ABrowserContext
)

Source from the content-addressed store, hash-verified

1388
1389
1390async def aexecute_action(
1391 action: Action, page: APage, browser_ctx: ABrowserContext
1392) -> APage:
1393 """Execute the async action on the ChromeDriver."""
1394 action_type = action["action_type"]
1395 match action_type:
1396 case ActionTypes.NONE:
1397 pass
1398 case ActionTypes.SCROLL:
1399 direction = "up" if "up" in action["direction"] else "down"
1400 await aexecute_scroll(direction, page)
1401 case ActionTypes.KEY_PRESS:
1402 keys = action["key_comb"]
1403 await aexecute_key_press(keys, page)
1404
1405 case ActionTypes.MOUSE_CLICK:
1406 await aexecute_mouse_click(
1407 action["coords"][0], action["coords"][1], page
1408 )
1409 case ActionTypes.MOUSE_HOVER:
1410 await aexecute_mouse_hover(
1411 action["coords"][0], action["coords"][1], page
1412 )
1413 case ActionTypes.KEYBOARD_TYPE:
1414 await aexecute_type(action["text"], page)
1415
1416 case ActionTypes.CLICK:
1417 # check each kind of locator in order
1418 # TODO[shuyanzh]: order is temp now
1419 if action["element_id"]:
1420 raise NotImplementedError
1421 elif action["element_role"] and action["element_name"]:
1422 element_role = int(action["element_role"])
1423 element_name = action["element_name"]
1424 nth = action["nth"]
1425 await aexecute_focus(element_role, element_name, nth, page)
1426 await aexecute_click_current(page)
1427 elif action["pw_code"]:
1428 parsed_code = parse_playwright_code(action["pw_code"])
1429 locator_code = parsed_code[:-1]
1430 # [shuyanzh], don't support action args and kwargs now
1431 await aexecute_playwright_click(
1432 locator_code=locator_code, page=page
1433 )
1434 else:
1435 raise ValueError("No proper locator found for click action")
1436 case ActionTypes.HOVER:
1437 if action["element_id"]:
1438 raise NotImplementedError
1439 elif action["element_role"] and action["element_name"]:
1440 element_role = int(action["element_role"])
1441 element_name = action["element_name"]
1442 nth = action["nth"]
1443 await aexecute_focus(element_role, element_name, nth, page)
1444 elif action["pw_code"]:
1445 parsed_code = parse_playwright_code(action["pw_code"])
1446 locator_code = parsed_code[:-1]
1447 # [shuyanzh], don't support action args and kwargs now

Callers 1

astepMethod · 0.85

Calls 14

aexecute_scrollFunction · 0.85
aexecute_key_pressFunction · 0.85
aexecute_mouse_clickFunction · 0.85
aexecute_mouse_hoverFunction · 0.85
aexecute_typeFunction · 0.85
aexecute_focusFunction · 0.85
aexecute_click_currentFunction · 0.85
parse_playwright_codeFunction · 0.85
aexecute_playwright_typeFunction · 0.85

Tested by

no test coverage detected