#!/usr/bin/env python
"""验证服务器上元素映射表服务是否正常加载"""
import json
import sys
import os

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from app.services.element_mapping_service import ElementMappingService

svc = ElementMappingService()
print(f"Enabled: {svc.is_enabled()}")
print(f"Elements count: {len(svc._elements)}")

keys = list(svc._elements.keys())
print(f"First 5 keys: {json.dumps(keys[:5], ensure_ascii=False)}")

# Test key matches
test_cases = [
    "点击【会议预约】分类",
    "点击【新建会议】按钮",
    "点击功能中心抽屉展开",
    "输入搜索关键词",
    "点击【会议服务统计】",
]

for step in test_cases:
    result = svc.get_selector(step, "click")
    if result:
        print(f"  [OK] {step} -> {result['selector']} (conf={result['confidence']})")
    else:
        print(f"  [MISS] {step} -> None")