aboutsummaryrefslogtreecommitdiff
path: root/upstreams/playwright-py/baseline/examples
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-11 17:05:03 -0500
committerCraig Jennings <c@cjennings.net>2026-06-11 17:05:03 -0500
commitda93ffd91dea133963ffceaff24d41bc76b8ff93 (patch)
tree6aac57d5eb712463a852c74e75150331be2298b1 /upstreams/playwright-py/baseline/examples
parent61e37f55c044ff7bbd41cb142ce9dfe232934216 (diff)
downloadrulesets-da93ffd91dea133963ffceaff24d41bc76b8ff93.tar.gz
rulesets-da93ffd91dea133963ffceaff24d41bc76b8ff93.zip
feat(commands): /update-skills syncs forks with upstream via 3-way merge
Upstream releases fixes worth pulling into the forks (arch-decide, playwright-js, playwright-py) without losing our local modifications. Each fork now has a manifest at upstreams/<name>/ plus a committed baseline snapshot that is the 3-way merge base. scripts/update-skills.py classifies each file's drift and merges to stdout. The command owns per-file confirmation, per-hunk conflict prompts, and every target write. I centralized manifests under upstreams/ instead of per-skill dotfile dirs because arch-decide is now two flat files in commands/ and can't carry one. A "files" map in its manifest handles the upstream rename of SKILL.md to arch-decide.md. I seeded baselines from today's upstream HEADs, so pre-existing local modifications classify as local-only from here on. git merge-file signals hard errors as exit 255, which subprocess reports as positive. The guard treats anything 128 and up as an error so a binary-file failure isn't misread as a conflict.
Diffstat (limited to 'upstreams/playwright-py/baseline/examples')
-rw-r--r--upstreams/playwright-py/baseline/examples/console_logging.py35
-rw-r--r--upstreams/playwright-py/baseline/examples/element_discovery.py40
-rw-r--r--upstreams/playwright-py/baseline/examples/static_html_automation.py33
3 files changed, 108 insertions, 0 deletions
diff --git a/upstreams/playwright-py/baseline/examples/console_logging.py b/upstreams/playwright-py/baseline/examples/console_logging.py
new file mode 100644
index 0000000..9329b5e
--- /dev/null
+++ b/upstreams/playwright-py/baseline/examples/console_logging.py
@@ -0,0 +1,35 @@
+from playwright.sync_api import sync_playwright
+
+# Example: Capturing console logs during browser automation
+
+url = 'http://localhost:5173' # Replace with your URL
+
+console_logs = []
+
+with sync_playwright() as p:
+ browser = p.chromium.launch(headless=True)
+ page = browser.new_page(viewport={'width': 1920, 'height': 1080})
+
+ # Set up console log capture
+ def handle_console_message(msg):
+ console_logs.append(f"[{msg.type}] {msg.text}")
+ print(f"Console: [{msg.type}] {msg.text}")
+
+ page.on("console", handle_console_message)
+
+ # Navigate to page
+ page.goto(url)
+ page.wait_for_load_state('networkidle')
+
+ # Interact with the page (triggers console logs)
+ page.click('text=Dashboard')
+ page.wait_for_timeout(1000)
+
+ browser.close()
+
+# Save console logs to file
+with open('/mnt/user-data/outputs/console.log', 'w') as f:
+ f.write('\n'.join(console_logs))
+
+print(f"\nCaptured {len(console_logs)} console messages")
+print(f"Logs saved to: /mnt/user-data/outputs/console.log") \ No newline at end of file
diff --git a/upstreams/playwright-py/baseline/examples/element_discovery.py b/upstreams/playwright-py/baseline/examples/element_discovery.py
new file mode 100644
index 0000000..917ba72
--- /dev/null
+++ b/upstreams/playwright-py/baseline/examples/element_discovery.py
@@ -0,0 +1,40 @@
+from playwright.sync_api import sync_playwright
+
+# Example: Discovering buttons and other elements on a page
+
+with sync_playwright() as p:
+ browser = p.chromium.launch(headless=True)
+ page = browser.new_page()
+
+ # Navigate to page and wait for it to fully load
+ page.goto('http://localhost:5173')
+ page.wait_for_load_state('networkidle')
+
+ # Discover all buttons on the page
+ buttons = page.locator('button').all()
+ print(f"Found {len(buttons)} buttons:")
+ for i, button in enumerate(buttons):
+ text = button.inner_text() if button.is_visible() else "[hidden]"
+ print(f" [{i}] {text}")
+
+ # Discover links
+ links = page.locator('a[href]').all()
+ print(f"\nFound {len(links)} links:")
+ for link in links[:5]: # Show first 5
+ text = link.inner_text().strip()
+ href = link.get_attribute('href')
+ print(f" - {text} -> {href}")
+
+ # Discover input fields
+ inputs = page.locator('input, textarea, select').all()
+ print(f"\nFound {len(inputs)} input fields:")
+ for input_elem in inputs:
+ name = input_elem.get_attribute('name') or input_elem.get_attribute('id') or "[unnamed]"
+ input_type = input_elem.get_attribute('type') or 'text'
+ print(f" - {name} ({input_type})")
+
+ # Take screenshot for visual reference
+ page.screenshot(path='/tmp/page_discovery.png', full_page=True)
+ print("\nScreenshot saved to /tmp/page_discovery.png")
+
+ browser.close() \ No newline at end of file
diff --git a/upstreams/playwright-py/baseline/examples/static_html_automation.py b/upstreams/playwright-py/baseline/examples/static_html_automation.py
new file mode 100644
index 0000000..90bbedc
--- /dev/null
+++ b/upstreams/playwright-py/baseline/examples/static_html_automation.py
@@ -0,0 +1,33 @@
+from playwright.sync_api import sync_playwright
+import os
+
+# Example: Automating interaction with static HTML files using file:// URLs
+
+html_file_path = os.path.abspath('path/to/your/file.html')
+file_url = f'file://{html_file_path}'
+
+with sync_playwright() as p:
+ browser = p.chromium.launch(headless=True)
+ page = browser.new_page(viewport={'width': 1920, 'height': 1080})
+
+ # Navigate to local HTML file
+ page.goto(file_url)
+
+ # Take screenshot
+ page.screenshot(path='/mnt/user-data/outputs/static_page.png', full_page=True)
+
+ # Interact with elements
+ page.click('text=Click Me')
+ page.fill('#name', 'John Doe')
+ page.fill('#email', 'john@example.com')
+
+ # Submit form
+ page.click('button[type="submit"]')
+ page.wait_for_timeout(500)
+
+ # Take final screenshot
+ page.screenshot(path='/mnt/user-data/outputs/after_submit.png', full_page=True)
+
+ browser.close()
+
+print("Static HTML automation completed!") \ No newline at end of file