* 查找表单字段(单个)
(fieldName)
| 89 | * 查找表单字段(单个) |
| 90 | */ |
| 91 | function findField(fieldName) { |
| 92 | // 1. 优先尝试 CSS 选择器 |
| 93 | const selectors = FIELD_SELECTORS[fieldName] || []; |
| 94 | for (const selector of selectors) { |
| 95 | try { |
| 96 | const element = document.querySelector(selector); |
| 97 | if (element && isVisible(element) && !element.disabled && !element.readOnly) { |
| 98 | return element; |
| 99 | } |
| 100 | } catch (e) { |
| 101 | // 忽略无效选择器 |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | // 2. 尝试智能标签匹配 |
| 106 | return findFieldByLabel(fieldName); |
| 107 | } |
| 108 | |
| 109 | |
| 110 | /** |
no test coverage detected