Skip to content

Commit ffebf6b

Browse files
committed
get html from playwright mcp
1 parent 6664b69 commit ffebf6b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/agentlab/backends/browser/mcp_playwright.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,15 @@ def step(self, action: ToolCallAction) -> dict:
4343
}
4444

4545
def page_html(self) -> str:
46-
return ""
46+
contents = self.call_tool("browser_evaluate", {"function": "document.documentElement.outerHTML"})
47+
raw_response = "\n".join([c.text for c in contents if c.type == "text"])
48+
try:
49+
_, half_response = raw_response.split("### Result", maxsplit=1)
50+
result_str, _ = half_response.split("\n### Ran", maxsplit=1)
51+
return result_str.strip()
52+
except Exception as e:
53+
logger.error(f"Error parsing page_html result: {e}. Raw result: {raw_response}")
54+
return ""
4755

4856
def page_axtree(self) -> str:
4957
contents = self.call_tool("browser_snapshot", {})

0 commit comments

Comments
 (0)