Skip to content

Commit 842ab03

Browse files
committed
fix: incompatibility issue of browser-use in version 0.1.41
1 parent 955cb4f commit 842ab03

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pip install -r requirements.txt
5555
For browser tools, install additional dependencies (python3.11+ required):
5656

5757
```bash
58-
pip install browser-use
58+
pip install browser-use==0.1.40
5959
playwright install
6060
```
6161

agentmesh/tools/browser/browser_tool.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def execute(self, params: Dict[str, Any]) -> ToolResult:
141141
return ToolResult.fail(result=f"Error executing browser action: {str(e)}")
142142

143143
async def _get_page_state(self, context: BrowserContext):
144-
state = await context.get_state()
144+
state = await self._get_state(context)
145145
include_attributes = ["img", "div", "button", "input"]
146146
elements = state.element_tree.clickable_elements_to_string(include_attributes)
147147
pattern = r'\[\d+\]<[^>]+\/>'
@@ -157,6 +157,12 @@ async def _get_page_state(self, context: BrowserContext):
157157
}
158158
return page_state
159159

160+
async def _get_state(self, context: BrowserContext, cache_clickable_elements_hashes=True):
161+
try:
162+
return await context.get_state()
163+
except TypeError:
164+
return await context.get_state(cache_clickable_elements_hashes=cache_clickable_elements_hashes)
165+
160166
async def _get_page_info(self, context: BrowserContext):
161167
page_state = await self._get_page_state(context)
162168
state_str = f"""## Current browser state

docs/README-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pip install -r requirements.txt
5151
如需使用浏览器工具,还需要额外安装依赖 (可选,需要 python3.11+):
5252

5353
```bash
54-
pip install browser-use
54+
pip install browser-use==0.1.40
5555
playwright install
5656
```
5757

0 commit comments

Comments
 (0)