File tree Expand file tree Collapse file tree 5 files changed +40
-1
lines changed
Expand file tree Collapse file tree 5 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 6363)
6464from .wait import wait_for
6565
66- __version__ = "0.90.0 "
66+ __version__ = "0.90.1 "
6767
6868__all__ = [
6969 # Core SDK
Original file line number Diff line number Diff line change @@ -145,6 +145,9 @@ def act( # noqa: C901
145145
146146 # Use provided options or create default
147147 snap_opts = snapshot_options or SnapshotOptions (limit = self .default_snapshot_limit )
148+ # Only set goal if not already provided
149+ if snap_opts .goal is None :
150+ snap_opts .goal = goal
148151
149152 # Convert screenshot config to dict if needed
150153 screenshot_param = snap_opts .screenshot
@@ -161,6 +164,7 @@ def act( # noqa: C901
161164 limit = snap_opts .limit ,
162165 filter = snap_opts .filter .model_dump () if snap_opts .filter else None ,
163166 use_api = snap_opts .use_api ,
167+ goal = snap_opts .goal , # Pass goal to snapshot
164168 )
165169
166170 if snap .status != "success" :
Original file line number Diff line number Diff line change @@ -116,6 +116,7 @@ class SnapshotOptions(BaseModel):
116116 use_api : bool | None = None # Force API vs extension
117117 save_trace : bool = False # Save raw_elements to JSON for benchmarking/training
118118 trace_path : str | None = None # Path to save trace (default: "trace_{timestamp}.json")
119+ goal : str | None = None # Optional goal/task description for the snapshot
119120
120121 class Config :
121122 arbitrary_types_allowed = True
Original file line number Diff line number Diff line change @@ -196,6 +196,7 @@ def _snapshot_via_api(
196196 "raw_elements" : raw_result .get ("raw_elements" , []), # Raw data needed for server processing
197197 "url" : raw_result .get ("url" , "" ),
198198 "viewport" : raw_result .get ("viewport" ),
199+ "goal" : options .goal , # Optional goal/task description
199200 "options" : {
200201 "limit" : options .limit ,
201202 "filter" : options .filter .model_dump () if options .filter else None ,
Original file line number Diff line number Diff line change @@ -101,3 +101,36 @@ def test_snapshot_save():
101101 assert "elements" in data
102102 finally :
103103 os .unlink (temp_path )
104+
105+
106+ @pytest .mark .requires_extension
107+ def test_snapshot_with_goal ():
108+ """Test snapshot with goal parameter"""
109+ with SentienceBrowser () as browser :
110+ browser .page .goto ("https://example.com" )
111+ browser .page .wait_for_load_state ("networkidle" )
112+
113+ # Test snapshot with goal
114+ snap = snapshot (browser , goal = "Find the main heading" )
115+
116+ assert snap .status == "success"
117+ assert snap .url == "https://example.com/"
118+ assert len (snap .elements ) > 0
119+
120+ # Verify snapshot works normally with goal parameter
121+ assert all (el .id >= 0 for el in snap .elements )
122+ assert all (
123+ el .role
124+ in [
125+ "button" ,
126+ "link" ,
127+ "textbox" ,
128+ "searchbox" ,
129+ "checkbox" ,
130+ "radio" ,
131+ "combobox" ,
132+ "image" ,
133+ "generic" ,
134+ ]
135+ for el in snap .elements
136+ )
You can’t perform that action at this time.
0 commit comments