JavaScript
javascript executes a snippet in the page context and optionally stores the return value in a variable. Use it for escape hatches: reading computed styles, querying global state, or tweaking third-party widgets.
yaml
- javascript:
code: |
return getComputedStyle(document.body).fontFamily;
as: body_fontEscape hatch, not a habit
Reaching for JavaScript usually means an assertion is missing or a locator is too brittle. Fix the locator first; drop to JS only when there is no other way.