Skip to content

Commit fc21b94

Browse files
committed
Removed frame_id empty string passing
1 parent 9ffaef3 commit fc21b94

File tree

3 files changed

+13
-23
lines changed

3 files changed

+13
-23
lines changed

src/stagehand/session.py

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import TYPE_CHECKING, Any, Union, Mapping, TypeVar, cast
5+
from typing import TYPE_CHECKING, Any, Union
66
from datetime import datetime
77
from typing_extensions import Unpack, Literal
88

@@ -24,15 +24,6 @@
2424
from .types.session_observe_response import SessionObserveResponse
2525
from .types.session_navigate_response import SessionNavigateResponse
2626

27-
TSessionParams = TypeVar("TSessionParams", bound=Mapping[str, Any])
28-
29-
30-
def _with_default_frame_id(params: TSessionParams) -> TSessionParams:
31-
prepared = dict(params)
32-
if "frame_id" not in prepared:
33-
prepared["frame_id"] = ""
34-
return cast(TSessionParams, prepared)
35-
3627
if TYPE_CHECKING:
3728
from ._client import Stagehand, AsyncStagehand
3829

@@ -62,7 +53,7 @@ def navigate(
6253
extra_query=extra_query,
6354
extra_body=extra_body,
6455
timeout=timeout,
65-
**_with_default_frame_id(params),
56+
**params,
6657
)
6758

6859
def act(
@@ -80,7 +71,7 @@ def act(
8071
extra_query=extra_query,
8172
extra_body=extra_body,
8273
timeout=timeout,
83-
**_with_default_frame_id(params),
74+
**params,
8475
)
8576

8677
def observe(
@@ -98,7 +89,7 @@ def observe(
9889
extra_query=extra_query,
9990
extra_body=extra_body,
10091
timeout=timeout,
101-
**_with_default_frame_id(params),
92+
**params,
10293
)
10394

10495
def extract(
@@ -116,7 +107,7 @@ def extract(
116107
extra_query=extra_query,
117108
extra_body=extra_body,
118109
timeout=timeout,
119-
**_with_default_frame_id(params),
110+
**params,
120111
)
121112

122113
def execute(
@@ -134,7 +125,7 @@ def execute(
134125
extra_query=extra_query,
135126
extra_body=extra_body,
136127
timeout=timeout,
137-
**_with_default_frame_id(params),
128+
**params,
138129
)
139130

140131
def end(
@@ -182,7 +173,7 @@ async def navigate(
182173
extra_query=extra_query,
183174
extra_body=extra_body,
184175
timeout=timeout,
185-
**_with_default_frame_id(params),
176+
**params,
186177
)
187178

188179
async def act(
@@ -200,7 +191,7 @@ async def act(
200191
extra_query=extra_query,
201192
extra_body=extra_body,
202193
timeout=timeout,
203-
**_with_default_frame_id(params),
194+
**params,
204195
)
205196

206197
async def observe(
@@ -218,7 +209,7 @@ async def observe(
218209
extra_query=extra_query,
219210
extra_body=extra_body,
220211
timeout=timeout,
221-
**_with_default_frame_id(params),
212+
**params,
222213
)
223214

224215
async def extract(
@@ -236,7 +227,7 @@ async def extract(
236227
extra_query=extra_query,
237228
extra_body=extra_body,
238229
timeout=timeout,
239-
**_with_default_frame_id(params),
230+
**params,
240231
)
241232

242233
async def execute(
@@ -254,7 +245,7 @@ async def execute(
254245
extra_query=extra_query,
255246
extra_body=extra_body,
256247
timeout=timeout,
257-
**_with_default_frame_id(params),
248+
**params,
258249
)
259250

260251
async def end(

test_local_mode.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
client.sessions.navigate(
4848
id=session_id,
4949
url="https://example.com",
50-
frame_id="",
5150
)
5251
print("✅ Navigation complete") # noqa: T201
5352

tests/test_sessions_create_helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_sessions_create_returns_bound_session(respx_mock: MockRouter, client: S
4444
assert navigate_route.called is True
4545
first_call = cast(Call, navigate_route.calls[0])
4646
request_body = json.loads(first_call.request.content)
47-
assert request_body["frameId"] == ""
47+
assert "frameId" not in request_body
4848

4949

5050
@pytest.mark.respx(base_url=base_url)
@@ -77,4 +77,4 @@ async def test_async_sessions_create_returns_bound_session(
7777
assert navigate_route.called is True
7878
first_call = cast(Call, navigate_route.calls[0])
7979
request_body = json.loads(first_call.request.content)
80-
assert request_body["frameId"] == ""
80+
assert "frameId" not in request_body

0 commit comments

Comments
 (0)