Skip to content

Commit 252e47e

Browse files
add ionwave test
1 parent 694c4fb commit 252e47e

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed

tests/regression/test_ionwave.py

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
"""
2+
Regression test for ionwave functionality.
3+
4+
This test verifies that navigation actions work correctly by clicking on links,
5+
based on the TypeScript ionwave evaluation.
6+
"""
7+
8+
import os
9+
import pytest
10+
import pytest_asyncio
11+
12+
from stagehand import Stagehand, StagehandConfig
13+
14+
15+
class TestIonwave:
16+
"""Regression test for ionwave functionality"""
17+
18+
@pytest.fixture(scope="class")
19+
def local_config(self):
20+
"""Configuration for LOCAL mode testing"""
21+
return StagehandConfig(
22+
env="LOCAL",
23+
model_name="gpt-4o-mini",
24+
headless=True,
25+
verbose=1,
26+
dom_settle_timeout_ms=2000,
27+
model_client_options={"apiKey": os.getenv("MODEL_API_KEY") or os.getenv("OPENAI_API_KEY")},
28+
)
29+
30+
@pytest.fixture(scope="class")
31+
def browserbase_config(self):
32+
"""Configuration for BROWSERBASE mode testing"""
33+
return StagehandConfig(
34+
env="BROWSERBASE",
35+
api_key=os.getenv("BROWSERBASE_API_KEY"),
36+
project_id=os.getenv("BROWSERBASE_PROJECT_ID"),
37+
model_name="gpt-4o",
38+
headless=False,
39+
verbose=2,
40+
model_client_options={"apiKey": os.getenv("MODEL_API_KEY") or os.getenv("OPENAI_API_KEY")},
41+
)
42+
43+
@pytest_asyncio.fixture
44+
async def local_stagehand(self, local_config):
45+
"""Create a Stagehand instance for LOCAL testing"""
46+
stagehand = Stagehand(config=local_config)
47+
await stagehand.init()
48+
yield stagehand
49+
await stagehand.close()
50+
51+
@pytest_asyncio.fixture
52+
async def browserbase_stagehand(self, browserbase_config):
53+
"""Create a Stagehand instance for BROWSERBASE testing"""
54+
if not (os.getenv("BROWSERBASE_API_KEY") and os.getenv("BROWSERBASE_PROJECT_ID")):
55+
pytest.skip("Browserbase credentials not available")
56+
57+
stagehand = Stagehand(config=browserbase_config)
58+
await stagehand.init()
59+
yield stagehand
60+
await stagehand.close()
61+
62+
@pytest.mark.asyncio
63+
@pytest.mark.regression
64+
@pytest.mark.local
65+
async def test_ionwave_local(self, local_stagehand):
66+
"""
67+
Regression test: ionwave
68+
69+
Mirrors the TypeScript ionwave evaluation:
70+
- Navigate to ionwave test site
71+
- Click on "Closed Bids" link
72+
- Verify navigation to closed-bids.html page
73+
"""
74+
stagehand = local_stagehand
75+
76+
await stagehand.page.goto("https://browserbase.github.io/stagehand-eval-sites/sites/ionwave/")
77+
78+
result = await stagehand.page.act('Click on "Closed Bids"')
79+
80+
current_url = stagehand.page.url
81+
expected_url = "https://browserbase.github.io/stagehand-eval-sites/sites/ionwave/closed-bids.html"
82+
83+
# Test passes if we successfully navigated to the expected URL
84+
assert current_url.startswith(expected_url), f"Expected URL to start with {expected_url}, but got {current_url}"
85+
86+
@pytest.mark.asyncio
87+
@pytest.mark.regression
88+
@pytest.mark.api
89+
@pytest.mark.skipif(
90+
not (os.getenv("BROWSERBASE_API_KEY") and os.getenv("BROWSERBASE_PROJECT_ID")),
91+
reason="Browserbase credentials not available"
92+
)
93+
async def test_ionwave_browserbase(self, browserbase_stagehand):
94+
"""
95+
Regression test: ionwave (Browserbase)
96+
97+
Same test as local but running in Browserbase environment.
98+
"""
99+
stagehand = browserbase_stagehand
100+
101+
await stagehand.page.goto("https://browserbase.github.io/stagehand-eval-sites/sites/ionwave/")
102+
103+
result = await stagehand.page.act('Click on "Closed Bids"')
104+
105+
current_url = stagehand.page.url
106+
expected_url = "https://browserbase.github.io/stagehand-eval-sites/sites/ionwave/closed-bids.html"
107+
108+
# Test passes if we successfully navigated to the expected URL
109+
assert current_url.startswith(expected_url), f"Expected URL to start with {expected_url}, but got {current_url}"

0 commit comments

Comments
 (0)