Skip to content

Commit f66e5dc

Browse files
committed
upgrade to bu==0.1.47
1 parent c9a226f commit f66e5dc

11 files changed

+61
-64
lines changed

Dockerfile

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,24 +67,23 @@ WORKDIR /app
6767

6868
# Copy requirements and install Python dependencies
6969
COPY requirements.txt .
70-
# Ensure 'patchright' is in your requirements.txt or install it directly
71-
# RUN pip install --no-cache-dir -r requirements.txt patchright # If not in requirements
70+
7271
RUN pip install --no-cache-dir -r requirements.txt
7372

74-
# Install Patchright browsers and dependencies
75-
# Patchright documentation suggests PLAYWRIGHT_BROWSERS_PATH is still relevant
76-
# or that Patchright installs to a similar default location that Playwright would.
77-
# Let's assume Patchright respects PLAYWRIGHT_BROWSERS_PATH or its default install location is findable.
73+
# Install playwright browsers and dependencies
74+
# playwright documentation suggests PLAYWRIGHT_BROWSERS_PATH is still relevant
75+
# or that playwright installs to a similar default location that Playwright would.
76+
# Let's assume playwright respects PLAYWRIGHT_BROWSERS_PATH or its default install location is findable.
7877
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-browsers
7978
RUN mkdir -p $PLAYWRIGHT_BROWSERS_PATH
8079

8180
# Install recommended: Google Chrome (instead of just Chromium for better undetectability)
82-
# The 'patchright install chrome' command might download and place it.
83-
# The '--with-deps' equivalent for patchright install is to run 'patchright install-deps chrome' after.
84-
# RUN patchright install chrome --with-deps
81+
# The 'playwright install chrome' command might download and place it.
82+
# The '--with-deps' equivalent for playwright install is to run 'playwright install-deps chrome' after.
83+
# RUN playwright install chrome --with-deps
8584

8685
# Alternative: Install Chromium if Google Chrome is problematic in certain environments
87-
RUN patchright install chromium --with-deps
86+
RUN playwright install chromium --with-deps
8887

8988

9089
# Copy the application code

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ Install Python packages:
6161
uv pip install -r requirements.txt
6262
```
6363

64-
Install Browsers in Patchright.
64+
Install Browsers in playwright.
6565
```bash
66-
patchright install --with-deps
66+
playwright install --with-deps
6767
```
6868
Or you can install specific browsers by running:
6969
```bash
70-
patchright install chromium --with-deps
70+
playwright install chromium --with-deps
7171
```
7272

7373
#### Step 4: Configure Environment

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ services:
5454

5555
# Display Settings
5656
- DISPLAY=:99
57-
# This ENV is used by the Dockerfile during build time if Patchright respects it.
57+
# This ENV is used by the Dockerfile during build time if playwright respects it.
5858
# It's not strictly needed at runtime by docker-compose unless your app or scripts also read it.
5959
- PLAYWRIGHT_BROWSERS_PATH=/ms-browsers # Matches Dockerfile ENV
6060
- RESOLUTION=${RESOLUTION:-1920x1080x24}

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
browser-use==0.1.45
1+
browser-use==0.1.47
22
pyperclip==1.9.0
33
gradio==5.27.0
44
json-repair

src/agent/browser_use/browser_use_agent.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
ToolCallingMethod,
1616
)
1717
from browser_use.browser.views import BrowserStateHistory
18-
from browser_use.telemetry.views import (
19-
AgentEndTelemetryEvent,
20-
)
2118
from browser_use.utils import time_execution_async
2219
from dotenv import load_dotenv
2320
from browser_use.agent.message_manager.utils import is_model_without_tool_support
@@ -144,19 +141,6 @@ async def run(
144141
# Unregister signal handlers before cleanup
145142
signal_handler.unregister()
146143

147-
self.telemetry.capture(
148-
AgentEndTelemetryEvent(
149-
agent_id=self.state.agent_id,
150-
is_done=self.state.history.is_done(),
151-
success=self.state.history.is_successful(),
152-
steps=self.state.n_steps,
153-
max_steps_reached=self.state.n_steps >= max_steps,
154-
errors=self.state.history.errors(),
155-
total_input_tokens=self.state.history.total_input_tokens(),
156-
total_duration_seconds=self.state.history.total_duration_seconds(),
157-
)
158-
)
159-
160144
if self.settings.save_playwright_script_path:
161145
logger.info(
162146
f'Agent run finished. Attempting to save Playwright script to: {self.settings.save_playwright_script_path}'

src/agent/deep_research/deep_research_agent.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ async def run_single_browser_task(
8181
bu_browser_context = None
8282
try:
8383
logger.info(f"Starting browser task for query: {task_query}")
84-
extra_args = [f"--window-size={window_w},{window_h}"]
84+
extra_args = []
8585
if use_own_browser:
8686
browser_binary_path = os.getenv("BROWSER_PATH", None) or browser_binary_path
8787
if browser_binary_path == "":
@@ -99,6 +99,10 @@ async def run_single_browser_task(
9999
extra_browser_args=extra_args,
100100
wss_url=wss_url,
101101
cdp_url=cdp_url,
102+
new_context_config=BrowserContextConfig(
103+
window_width=window_w,
104+
window_height=window_h,
105+
)
102106
)
103107
)
104108

src/browser/custom_browser.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import asyncio
22
import pdb
33

4-
from patchright.async_api import Browser as PlaywrightBrowser
5-
from patchright.async_api import (
4+
from playwright.async_api import Browser as PlaywrightBrowser
5+
from playwright.async_api import (
66
BrowserContext as PlaywrightBrowserContext,
77
)
8-
from patchright.async_api import (
8+
from playwright.async_api import (
99
Playwright,
1010
async_playwright,
1111
)
1212
from browser_use.browser.browser import Browser, IN_DOCKER
1313
from browser_use.browser.context import BrowserContext, BrowserContextConfig
14-
from patchright.async_api import BrowserContext as PlaywrightBrowserContext
14+
from playwright.async_api import BrowserContext as PlaywrightBrowserContext
1515
import logging
1616

1717
from browser_use.browser.chrome import (
@@ -48,9 +48,13 @@ async def _setup_builtin_browser(self, playwright: Playwright) -> PlaywrightBrow
4848
if (
4949
not self.config.headless
5050
and hasattr(self.config, 'new_context_config')
51-
and hasattr(self.config.new_context_config, 'browser_window_size')
51+
and hasattr(self.config.new_context_config, 'window_width')
52+
and hasattr(self.config.new_context_config, 'window_height')
5253
):
53-
screen_size = self.config.new_context_config.browser_window_size.model_dump()
54+
screen_size = {
55+
'width': self.config.new_context_config.window_width,
56+
'height': self.config.new_context_config.window_height,
57+
}
5458
offset_x, offset_y = get_window_adjustments()
5559
elif self.config.headless:
5660
screen_size = {'width': 1920, 'height': 1080}
@@ -67,17 +71,12 @@ async def _setup_builtin_browser(self, playwright: Playwright) -> PlaywrightBrow
6771
*(CHROME_DISABLE_SECURITY_ARGS if self.config.disable_security else []),
6872
*(CHROME_DETERMINISTIC_RENDERING_ARGS if self.config.deterministic_rendering else []),
6973
f'--window-position={offset_x},{offset_y}',
74+
f'--window-size={screen_size["width"]},{screen_size["height"]}',
7075
*self.config.extra_browser_args,
7176
}
72-
contain_window_size = False
73-
for arg in self.config.extra_browser_args:
74-
if "--window-size" in arg:
75-
contain_window_size = True
76-
break
77-
if not contain_window_size:
78-
chrome_args.add(f'--window-size={screen_size["width"]},{screen_size["height"]}')
7977

80-
# check if port 9222 is already taken, if so remove the remote-debugging-port arg to prevent conflicts
78+
# check if chrome remote debugging port is already taken,
79+
# if so remove the remote-debugging-port arg to prevent conflicts
8180
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
8281
if s.connect_ex(('localhost', self.config.chrome_remote_debugging_port)) == 0:
8382
chrome_args.remove(f'--remote-debugging-port={self.config.chrome_remote_debugging_port}')
@@ -100,6 +99,7 @@ async def _setup_builtin_browser(self, playwright: Playwright) -> PlaywrightBrow
10099
}
101100

102101
browser = await browser_class.launch(
102+
channel='chromium', # https://github.com/microsoft/playwright/issues/33566
103103
headless=self.config.headless,
104104
args=args[self.config.browser_class],
105105
proxy=self.config.proxy.model_dump() if self.config.proxy else None,

src/browser/custom_context.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
from browser_use.browser.browser import Browser, IN_DOCKER
66
from browser_use.browser.context import BrowserContext, BrowserContextConfig
7-
from patchright.async_api import Browser as PlaywrightBrowser
8-
from patchright.async_api import BrowserContext as PlaywrightBrowserContext
7+
from playwright.async_api import Browser as PlaywrightBrowser
8+
from playwright.async_api import BrowserContext as PlaywrightBrowserContext
99
from typing import Optional
1010
from browser_use.browser.context import BrowserContextState
1111

src/webui/components/browser_use_agent_tab.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ async def ask_callback_wrapper(
450450
# Create Browser if needed
451451
if not webui_manager.bu_browser:
452452
logger.info("Launching new browser instance.")
453-
extra_args = [f"--window-size={window_w},{window_h}"]
453+
extra_args = []
454454
if use_own_browser:
455455
browser_binary_path = os.getenv("BROWSER_PATH", None) or browser_binary_path
456456
if browser_binary_path == "":
@@ -469,6 +469,10 @@ async def ask_callback_wrapper(
469469
extra_browser_args=extra_args,
470470
wss_url=wss_url,
471471
cdp_url=cdp_url,
472+
new_context_config=BrowserContextConfig(
473+
window_width=window_w,
474+
window_height=window_h,
475+
)
472476
)
473477
)
474478

tests/test_agents.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,19 @@ async def test_browser_use_agent():
2929
from src.utils import llm_provider
3030
from src.agent.browser_use.browser_use_agent import BrowserUseAgent
3131

32-
# llm = utils.get_llm_model(
33-
# provider="openai",
34-
# model_name="gpt-4o",
35-
# temperature=0.8,
36-
# base_url=os.getenv("OPENAI_ENDPOINT", ""),
37-
# api_key=os.getenv("OPENAI_API_KEY", ""),
38-
# )
39-
4032
llm = llm_provider.get_llm_model(
41-
provider="google",
42-
model_name="gemini-2.0-flash",
43-
temperature=0.6,
44-
api_key=os.getenv("GOOGLE_API_KEY", "")
33+
provider="openai",
34+
model_name="gpt-4o",
35+
temperature=0.8,
4536
)
4637

38+
# llm = llm_provider.get_llm_model(
39+
# provider="google",
40+
# model_name="gemini-2.0-flash",
41+
# temperature=0.6,
42+
# api_key=os.getenv("GOOGLE_API_KEY", "")
43+
# )
44+
4745
# llm = utils.get_llm_model(
4846
# provider="deepseek",
4947
# model_name="deepseek-reasoner",
@@ -104,7 +102,7 @@ async def test_browser_use_agent():
104102
browser_context = None
105103

106104
try:
107-
extra_browser_args = [f"--window-size={window_w},{window_h}"]
105+
extra_browser_args = []
108106
if use_own_browser:
109107
browser_binary_path = os.getenv("BROWSER_PATH", None)
110108
if browser_binary_path == "":
@@ -119,6 +117,10 @@ async def test_browser_use_agent():
119117
headless=False,
120118
browser_binary_path=browser_binary_path,
121119
extra_browser_args=extra_browser_args,
120+
new_context_config=BrowserContextConfig(
121+
window_width=window_w,
122+
window_height=window_h,
123+
)
122124
)
123125
)
124126
browser_context = await browser.new_context(
@@ -256,7 +258,7 @@ async def test_browser_use_parallel():
256258
browser_context = None
257259

258260
try:
259-
extra_browser_args = [f"--window-size={window_w},{window_h}"]
261+
extra_browser_args = []
260262
if use_own_browser:
261263
browser_binary_path = os.getenv("BROWSER_PATH", None)
262264
if browser_binary_path == "":
@@ -271,6 +273,10 @@ async def test_browser_use_parallel():
271273
headless=False,
272274
browser_binary_path=browser_binary_path,
273275
extra_browser_args=extra_browser_args,
276+
new_context_config=BrowserContextConfig(
277+
window_width=window_w,
278+
window_height=window_h,
279+
)
274280
)
275281
)
276282
browser_context = await browser.new_context(

tests/test_playwright.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
def test_connect_browser():
88
import os
9-
from patchright.sync_api import sync_playwright
9+
from playwright.sync_api import sync_playwright
1010

1111
chrome_exe = os.getenv("CHROME_PATH", "")
1212
chrome_use_data = os.getenv("CHROME_USER_DATA", "")

0 commit comments

Comments
 (0)