AutoQLLegacy → AgentQL migrator
Live demo · heuristic translator · no API key

Brittle locators in.
Semantic queries out.

Paste a Playwright or Selenium script. The same parse → translate → generate pipeline as the CLI rewrites CSS/XPath call sites into an AgentQL query_elements script — instantly, in the browser.

01
ParseWalk locator(), fill/click, and find_element call sites.
02
TranslateName each control from test ids, name, type, then classes.
03
GenerateEmit a sync Playwright module that queries by role, not path.
Legacy scriptsample_legacy.py
Generated AgentQL4 fields
"""
Auto-generated AgentQL migration of sample_legacy.py.

Regenerate with ``python generator.py`` — do not hand-edit locators here.
Requires AGENTQL_API_KEY (see .env.example).
"""

import agentql
from playwright.sync_api import sync_playwright

QUERY = """
{
    user_input
    icon_eye_button
    pwd_input
    btn_primary_button
}
"""


def run_migrated_flow() -> None:
    """Run the migrated flow with semantic AgentQL selectors."""
    with sync_playwright() as playwright:
        browser = playwright.chromium.launch(headless=True)
        page = agentql.wrap(browser.new_page())
        page.goto('https://example.com/login')

        elements = page.query_elements(QUERY)
        elements.user_input.fill('demo_user')
        elements.icon_eye_button.click()
        elements.pwd_input.fill('s3cret!')
        elements.btn_primary_button.click()

        browser.close()


if __name__ == "__main__":
    run_migrated_flow()

Locator map

4 locators3 css1 xpathURL https://example.com/login
{
    user_input
    icon_eye_button
    pwd_input
    btn_primary_button
}
LineActionKindBrittle selectorAgentQL name
19fillcssdiv#app > div.container > form.login-form > input[name='user']user_input
24clickcssdiv > ul.toolbar > li:nth-child(2) > button.icon-eyeicon_eye_button
27fillcssform[action='/auth/login'] input[type='password'][data-testid='pwd']pwd_input
32clickxpath//div[@id='footer']//button[contains(@class, 'btn-primary')]btn_primary_button

This demo runs the CLI's heuristic translator in the browser (the same names you get from python migrator.py --fallback). The Python CLI can also call gpt-4o-mini when OPENAI_API_KEY is set. Generated scripts need AGENTQL_API_KEY at runtime.