Install
openclaw skills install @paudyyin/browser-smart-clickRetry browser clicks with automatic obstacle detection and dismissal. Use when browser tool clicks fail due to cookie banners, modals, or fixed headers blocking the target element.
openclaw skills install @paudyyin/browser-smart-click解决 Playwright/OpenClaw browser 工具点击元素时被其他元素遮挡导致失败的问题�?
browser click 报错 element is obscured / interceptedfrom smart_click import SmartClick, smart_click, wait_for_clickable
一行调用智能点击:
result = await smart_click(page, '#submit-btn')
if result.success:
print("Clicked!")
else:
print(f"Failed: {result.message}")
if result.blocked:
print(f"Blocked by: {result.blocker}")
等待元素可见且不被遮挡:
clickable = await wait_for_clickable(page, '#btn', timeout=5000)
if clickable:
await page.click('#btn')
sc = SmartClick(auto_dismiss=True, max_retries=3)
# 基础点击
result = await sc.click(page, '#btn')
# 带重试的点击(滚�?�?JS click 回退�?result = await sc.click_with_retry(page, '#btn', max_retries=3)
# 等待可点�?ok = await sc.wait_for_clickable(page, '#btn', timeout=10000)
{
"success": true,
"target": {"selector": "#submit-btn", "text": "Submit"},
"blocked": false,
"blocker": null,
"retry_count": 0,
"message": "Clicked successfully"
}
被遮挡时�?
{
"success": false,
"target": {"selector": "#submit-btn", "text": "Submit"},
"blocked": true,
"blocker": {
"tag": "div",
"class_name": "cookie-banner",
"text": "We use cookies",
"bounding_box": {"x": 0, "y": 0, "width": 800, "height": 100},
"attributes": {}
},
"retry_count": 1,
"message": "Element blocked by: <div class=\"cookie-banner\"> text=\"We use cookies\""
}
| 遮挡类型 | 检测方�? | 处理策略 |
|---|---|---|
| Cookie Banner | class/id 包含 cookie/consent/gdpr | 点击 Accept/同意/允许 按钮 |
| Modal/Dialog | role=dialog �?class 包含 modal/popup | 点击 × 关闭按钮,或�?Escape |
| Fixed Header | style 包含 position:fixed/sticky | 滚动页面后重�? |
| 未知遮挡 | elementFromPoint 检�? | �?Escape 后重�? |
skills/browser-smart-click/
├── SKILL.md # 本文�?├── scripts/
�? ├── smart_click.py # 核心实现
�? └── test_smart_click.py # 测试用例
└── references/
└── usage.md # 详细使用文档
cd skills/browser-smart-click/scripts
pytest test_smart_click.py -v
�?skill 不替�?OpenClaw browser 工具,而是作为补充�?
browser snapshot 获取页面状�?2. �?browser act kind=click 尝试点击browser act evaluate 中直接使用遮挡检�?JS