@@ -300,7 +300,7 @@ def __init__(
300
300
301
301
# Telemetry
302
302
self .telemetry = ProductTelemetry ()
303
-
303
+
304
304
self .action_log = []
305
305
self .script_format = None # 'browserql' or 'baas_v2'
306
306
@@ -993,24 +993,24 @@ async def multi_act(
993
993
if not result .error :
994
994
action_type = action .get_action_type ()
995
995
action_data = {
996
- " action_type" : action_type ,
997
- " params" : action .model_dump (exclude_unset = True ),
998
- " selector" : None ,
999
- " timestamp" : time .time ()
996
+ ' action_type' : action_type ,
997
+ ' params' : action .model_dump (exclude_unset = True ),
998
+ ' selector' : None ,
999
+ ' timestamp' : time .time (),
1000
1000
}
1001
-
1001
+
1002
1002
if action .get_index () is not None :
1003
1003
element = cached_selector_map .get (action .get_index ())
1004
1004
if element :
1005
- action_data [" selector" ] = {
1006
- " xpath" : element .xpath ,
1007
- " tag_name" : element .tag_name ,
1008
- " attributes" : element .attributes ,
1009
- " index" : action .get_index (),
1010
- " is_visible" : element .is_visible ,
1011
- " is_interactive" : element .is_interactive
1005
+ action_data [' selector' ] = {
1006
+ ' xpath' : element .xpath ,
1007
+ ' tag_name' : element .tag_name ,
1008
+ ' attributes' : element .attributes ,
1009
+ ' index' : action .get_index (),
1010
+ ' is_visible' : element .is_visible ,
1011
+ ' is_interactive' : element .is_interactive ,
1012
1012
}
1013
-
1013
+
1014
1014
self .action_log .append (action_data )
1015
1015
logger .debug (f'Logged action { action_type } for script generation' )
1016
1016
@@ -1419,37 +1419,37 @@ async def _update_action_models_for_page(self, page) -> None:
1419
1419
# Update done action model too
1420
1420
self .DoneActionModel = self .controller .registry .create_action_model (include_actions = ['done' ], page = page )
1421
1421
self .DoneAgentOutput = AgentOutput .type_with_custom_actions (self .DoneActionModel )
1422
-
1422
+
1423
1423
def get_action_log (self ) -> List [Dict ]:
1424
1424
"""
1425
1425
Get the current action log.
1426
-
1426
+
1427
1427
Returns:
1428
1428
List[Dict]: List of logged actions
1429
1429
"""
1430
1430
return self .action_log
1431
-
1431
+
1432
1432
def clear_action_log (self ) -> None :
1433
1433
"""Clear the action log."""
1434
1434
self .action_log = []
1435
-
1435
+
1436
1436
def set_script_format (self , format_type : str ) -> None :
1437
1437
"""
1438
1438
Set the preferred script format.
1439
-
1439
+
1440
1440
Args:
1441
1441
format_type: Script format type ('browserql' or 'baas_v2')
1442
1442
"""
1443
1443
self .script_format = format_type
1444
-
1444
+
1445
1445
def get_script (self , format_type : Optional [str ] = None , ** kwargs ) -> str :
1446
1446
"""
1447
1447
Generate a script from the action log.
1448
-
1448
+
1449
1449
Args:
1450
1450
format_type: Script format type ('browserql' or 'baas_v2')
1451
1451
**kwargs: Additional arguments for the converter
1452
-
1452
+
1453
1453
Returns:
1454
1454
str: Generated script
1455
1455
"""
0 commit comments