findElement function

Last updated: 2026-03-05T20:45:07.036Z

Metrics

LOC: 24 Complexity: 7 Params: 1

Signature

findElement(step: FlowStep): : Element | null

Source Code

function findElement(step: FlowStep): Element | null {
  // Try smart selectors first (ordered by priority)
  if (step.smartSelectors?.length) {
    for (const ss of step.smartSelectors) {
      try {
        const el = document.querySelector(ss.value);
        if (el) return el;
      } catch {
        // invalid selector — skip
      }
    }
  }

  // Fallback to primary selector
  if (step.selector) {
    try {
      return document.querySelector(step.selector);
    } catch {
      return null;
    }
  }

  return null;
}

No outgoing dependencies.

Impact (Incoming)

graph LR findElement["findElement"] requireElement["requireElement"] handleWait["handleWait"] handlePressKey["handlePressKey"] handleAssert["handleAssert"] highlightElement["highlightElement"] requireElement -->|calls| findElement handleWait -->|calls| findElement handlePressKey -->|calls| findElement handleAssert -->|calls| findElement highlightElement -->|calls| findElement style findElement fill:#dbeafe,stroke:#2563eb,stroke-width:2px click findElement "db37f185eea489b4.html" click requireElement "54b35883ca14f405.html" click handleWait "1e0c6f2b3548f948.html" click handlePressKey "195a61c527b09c31.html" click handleAssert "fb80a5184e1878d1.html" click highlightElement "d623ce50223cce1c.html"
SourceType
requireElement calls
handleWait calls
handlePressKey calls
handleAssert calls
highlightElement calls