Loading...
Loading...
Compare original and translation side by side
scripts/with_server.py--helpscripts/with_server.py--helpUser task → Is it static HTML?
├─ Yes → Read HTML file directly to identify selectors
│ ├─ Success → Write Playwright script using selectors
│ └─ Fails/Incomplete → Treat as dynamic (below)
│
└─ No (dynamic webapp) → Is the server already running?
├─ No → Run: python scripts/with_server.py --help
│ Then use the helper + write simplified Playwright script
│
└─ Yes → Reconnaissance-then-action:
1. Navigate and wait for networkidle
2. Take screenshot or inspect DOM
3. Identify selectors from rendered state
4. Execute actions with discovered selectors用户任务 → 是否为静态HTML?
├─ 是 → 直接读取HTML文件以定位选择器
│ ├─ 成功 → 使用选择器编写Playwright脚本
│ └─ 失败/不完整 → 按动态应用处理(见下方)
│
└─ 否(动态Web应用) → 服务器是否已运行?
├─ 否 → 运行:python scripts/with_server.py --help
│ 然后使用辅助脚本 + 编写简化的Playwright脚本
│
└─ 是 → 先侦察再执行:
1. 导航至页面并等待networkidle状态
2. 截取截图或检查DOM
3. 从渲染状态中定位选择器
4. 使用找到的选择器执行操作--helppython scripts/with_server.py --server "npm run dev" --port 5173 -- python your_automation.pypython scripts/with_server.py \
--server "cd backend && python server.py" --port 3000 \
--server "cd frontend && npm run dev" --port 5173 \
-- python your_automation.pyfrom playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch(headless=True) # Always launch chromium in headless mode
page = browser.new_page()
page.goto('http://localhost:5173') # Server already running and ready
page.wait_for_load_state('networkidle') # CRITICAL: Wait for JS to execute
# ... your automation logic
browser.close()--helppython scripts/with_server.py --server "npm run dev" --port 5173 -- python your_automation.pypython scripts/with_server.py \
--server "cd backend && python server.py" --port 3000 \
--server "cd frontend && npm run dev" --port 5173 \
-- python your_automation.pyfrom playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch(headless=True) # Always launch chromium in headless mode
page = browser.new_page()
page.goto('http://localhost:5173') # Server already running and ready
page.wait_for_load_state('networkidle') # CRITICAL: Wait for JS to execute
# ... your automation logic
browser.close()page.screenshot(path='/tmp/inspect.png', full_page=True)
content = page.content()
page.locator('button').all()page.screenshot(path='/tmp/inspect.png', full_page=True)
content = page.content()
page.locator('button').all()networkidlepage.wait_for_load_state('networkidle')networkidlepage.wait_for_load_state('networkidle')scripts/--helpsync_playwright()text=role=page.wait_for_selector()page.wait_for_timeout()scripts/--helpsync_playwright()text=role=page.wait_for_selector()page.wait_for_timeout()element_discovery.pystatic_html_automation.pyconsole_logging.pyelement_discovery.pystatic_html_automation.pyconsole_logging.py