(selector: string, indexValue: number, property: string)
| 345 | } |
| 346 | |
| 347 | function buildAgentNthPropertyScript(selector: string, indexValue: number, property: string): string { |
| 348 | const payload = { selector, index: indexValue, property }; |
| 349 | return buildEvalScript(` |
| 350 | const payload = ${JSON.stringify(payload)}; |
| 351 | let nodes = []; |
| 352 | try { |
| 353 | nodes = Array.from(document.querySelectorAll(payload.selector)); |
| 354 | } catch { |
| 355 | return { ok: false, error: "Invalid selector" }; |
| 356 | } |
| 357 | const element = nodes[payload.index]; |
| 358 | if (!element) return { ok: false, error: "Element not found" }; |
| 359 | return { ok: true, value: element[payload.property] }; |
| 360 | `); |
| 361 | } |
| 362 | |
| 363 | function buildAgentOuterHtmlScript(selector: string, indexValue: number): string { |
| 364 | const payload = { selector, index: indexValue }; |
no test coverage detected