fix: 改进截图逻辑,直接截取表格元素

尝试截取table.ltable元素来获取完整内容,而不是依赖full_page参数。

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-14 16:08:41 +08:00
parent 4400ded86a
commit b408e78c74

View File

@@ -1361,10 +1361,29 @@ class PlaywrightAutomation:
# 先保存到临时文件
temp_filepath = filepath + '.tmp'
# 获取iframe并截取完整内容
# 获取iframe
iframe = self.get_iframe_safe()
if iframe:
# iframe内容进行全页截图
# 尝试截取iframe内的主要内容区域
try:
# 查找内容表格
table_locator = iframe.locator("table.ltable")
if table_locator.count() > 0:
table_locator.first.screenshot(
path=temp_filepath,
type='jpeg',
quality=100
)
else:
# 如果没有表格截取整个body内容
iframe.locator("body").screenshot(
path=temp_filepath,
type='jpeg',
quality=100
)
except Exception as e:
self.log(f"元素截图失败: {e},尝试全页截图")
# 回退到iframe全页截图
iframe.screenshot(
path=temp_filepath,
type='jpeg',