Prompt
How do I automate a browser flow that logs in, clicks through steps, and exports data?
Latest observation
Oct 26, 2026
OpenAI APIWeb search: off
You can automate this with a browser automation tool like Playwright or Selenium. The basic pattern is:
- Open the site
- Log in
- Click through each step
- Wait for the export to be generated
- Download/save the file
Recommended: Playwright
Playwright is usually the easiest for modern sites because it handles waits, downloads, tabs, and dynamic UI well.
Example in Python
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch(headless=False)
page = browser.new_page()
# Go to login page
page.goto("https://example.com/login")
# Fill credentials
page.fill("#username", "your_username")
page.fill("#password", "your_password")
page.click("button[type=submit]")
# Wait for login to complete
page.wait_for_url("https://example.com/dashboard")
# Click through workflow
page.click("text=Reports")
page.click("text=Export")
page.click("text=CSV")
# Handle file download
with page.expect_download() as download_info:
page.click("text=Download")
download = download_info.value
download.save_as("export.csv")
browser.close()
If the site uses multi-step navigation
You can chain actions like this:
page.click("text=Next")
page.wait_for_load_state("networkidle")
page.click("text=Confirm")
If there are modals, dropdowns, or dynamic elements, you may need selectors like:
- CSS:
#id,.class,button.submit - Text:
text=Export - XPath:
xpath=//button[contains(text(), 'Export')]
For more reliable automation
- Use explicit waits instead of fixed
sleeps - Prefer stable selectors like
data-testid - Save login state so you don’t log in every run
- Handle 2FA if required
- If export is generated in the browser, use download handlers
- If export appears as a new page/tab, switch to it
Selenium alternative
If you already use Selenium, the flow is similar, but Playwright is generally more robust for downloads and modern web apps.
If login includes 2FA or captcha
- 2FA: you may need a semi-manual step or app-specific token
- Captcha: do not try to bypass it; automate only where permitted
Best practice for production
- Store credentials in environment variables or a secrets manager
- Add retries and error logging
- Verify the export file exists and is non-empty
- Run headless in CI only after it works reliably in headed mode
If you want, I can give you:
- a Playwright Python script
- a Selenium version
- or help you target the specific site’s selectors if you share the flow details.
Brands