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:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user