kimsiaK
Windmillβ€’2y agoβ€’
13 replies
kimsia

[Solved] Browser automation self-hosted: python example for initial login

i have a use case where i need to login to substack manually using my username and password. then followed by my TOTP MFA code.

once that's done, i want the rest of the browser automation take over in terms of downloading invoices.

I found https://www.windmill.dev/docs/advanced/browser_automation but the examples are all not python.

I used claude and tried

import os
from playwright.sync_api import sync_playwright
import wmill

# You can import any PyPi package.
# See here for more info: https://www.windmill.dev/docs/advanced/dependencies_in_python

# you can use typed resources by doing a type alias to dict
# postgresql = dict


def main():
    with sync_playwright() as p:
        browser = p.chromium.launch(executable_path="/usr/bin/chromium")

        page = browser.new_page()
        page.goto("https://google.com")

        title = page.title()

        browser.close()

        return title


what happens is

Error: BrowserType.launch: Failed to launch chromium because executable doesn't exist at /usr/bin/chromium
  File "/tmp/windmill/wk-default-6f5cff974f78-sYQ4l/019102ae-1ce1-eea8-9b82-0fc2d2ee6b6b/u/kimsia/browser_automate_playwright.py", line 14, in main
    browser = p.chromium.launch(executable_path="/usr/bin/chromium")
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


I am running locally using docker in my macOS laptop M1

how do i solve this?

I am on the Pro Plan trial period.
Was this page helpful?