Skip to main content
Safari exposes web content through the Accessibility tree, allowing you to interact with web pages using the same commands as native apps.

Overview

Safari is unique among browsers because it exposes web content as Accessibility nodes. This means you can use agent-native to:
  • Navigate to URLs
  • Click links and buttons
  • Fill forms
  • Read page content
  • Interact with web applications
AX tree peers into browsers — Safari and Chrome expose web content as AX nodes, making web automation possible without browser-specific APIs.See SKILL.md:166 for details.

Core workflow

1

Open Safari

2

Navigate to URL

Safari’s address bar is an AXTextField. Find it and fill it:
3

Re-snapshot to see page content

Web elements appear with their semantic roles: AXButton, AXLink, AXTextField, etc.
4

Interact with page elements

Safari’s Accessibility tree

Safari represents web pages with semantic HTML roles mapped to AX roles: See AXEngine.swift:196-234 for how nodes are built from AX attributes.

Entering URLs

Keyboard shortcuts (cmd+l) are fastest for repetitive tasks.

Reloading pages

Opening new tabs

Form filling

Text inputs

Checkboxes

See InteractionCommands.swift for the select implementation.

Radio buttons

Submit buttons

Example: GitHub login

Complete workflow for logging into GitHub:

Reading page content

Get text from elements

Get page title

Check element states

Working with dynamic content

Waiting for elements

Use wait to wait for elements to appear:
See WaitCommand.swift for implementation.

Handling page loads

Re-snapshotting after interactions

Common Safari keyboard shortcuts

Best practices

Wait for page loads

Always add delays after navigation:

Use keyboard shortcuts

Shortcuts are more reliable than clicking toolbar buttons:

Check page titles

Verify navigation by checking titles:

Handle dynamic content

Use wait for elements that load asynchronously:

Troubleshooting

Possible causes:
  • Page not fully loaded
  • Content is in an iframe
  • Elements are dynamically rendered
Solutions:
  1. Wait longer for page load:
  2. Check full tree without -i flag:
  3. Try increasing depth:
Solutions:
  1. Use keyboard shortcut instead:
  2. Search for “Address” or “Search”:
Possible causes:
  • Submit button requires specific event
  • Form validation failing
Solutions:
  1. Try pressing Enter instead of clicking:
  2. Check if validation errors appear:
  3. Verify all required fields are filled
Problem: Multiple elements with similar titles.Solutions:
  1. Use more specific filters:
  2. Use index to select specific match:
  3. Inspect elements to verify:
Problem: Snapshot shows old content after interaction.Cause: Need to wait for page update.Solutions:
  1. Add delay before re-snapshotting:
  2. Use wait for specific element:

Limitations

Safari AX limitations:
  • Some JavaScript-heavy SPAs may have incomplete AX trees
  • Canvas-based content (games, visual editors) is not accessible
  • Shadow DOM elements may be hidden
  • Some modern frameworks render minimal semantic HTML
For complex web automation, consider:
  • Using simpler, more accessible websites
  • Combining with screenshots for visual verification
  • Using keyboard shortcuts when AX tree is sparse
  • Testing with Safari’s Accessibility Inspector first

Next steps

Electron apps

Automate Slack, Discord, and VS Code

System Settings

Configure macOS system settings

Troubleshooting

Fix common issues and errors

API reference

Explore all commands