{"library":"robocorp-browser","title":"Robocorp Browser","description":"The `robocorp-browser` package is a Python library for browser automation, acting as a lightweight wrapper around the Playwright project. It provides quality-of-life improvements, such as automatic lifecycle management for Playwright objects, and is primarily designed to be used within the Robocorp automation framework, especially with `robocorp-tasks`. The current version is 2.4.0. It is actively maintained as part of the broader Robocorp ecosystem.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install robocorp-browser"],"cli":null},"imports":["from robocorp import browser","from robocorp.tasks import task","from robocorp import vault"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom robocorp import browser\nfrom robocorp.tasks import task\nfrom robocorp import vault # For secret management example\n\n@task\ndef automate_browser_example():\n    \"\"\"Start a browser, navigate, and interact with a page.\"\"\"\n    # Configure browser settings (optional)\n    browser.configure(\n        browser_engine=\"chromium\",\n        headless=True, # Set to False to see the browser UI\n        slowmo=100, # Run interactions in slow motion (milliseconds)\n        screenshot=\"only-on-failure\", # Capture screenshot on error\n    )\n\n    # Get a secret (example: login credentials)\n    # In a real scenario, configure 'default-account' in Robocorp Vault\n    # For quickstart, we use environment variables as a fallback\n    username = os.environ.get('TEST_USERNAME', 'user')\n    password = os.environ.get('TEST_PASSWORD', 'pass')\n    \n    try:\n        account = vault.get_secret(\"default-account\")\n        username = account[\"username\"]\n        password = account[\"password\"]\n    except Exception:\n        print(\"Warning: Could not get secret 'default-account'. Using environment variables or defaults.\")\n\n    # Navigate to a page (this will automatically launch the browser if not already open)\n    page = browser.goto(\"https://www.example.com/login\") # Replace with a real login page\n\n    # Interact with elements using Playwright API\n    # Example: fill login form (replace with actual selectors)\n    # page.fill(\"#username_field\", username)\n    # page.fill(\"#password_field\", password)\n    # page.click(\"#login_button\")\n\n    # Perform some action, e.g., take a screenshot\n    browser.screenshot(page=page, path=\"output/example_screenshot.png\")\n    print(f\"Navigated to {page.url} and took a screenshot.\")\n\n    # The browser instance is automatically closed when the task finishes.\n","lang":"python","description":"This quickstart demonstrates how to initialize the browser, configure its behavior (like headless mode and slow motion), navigate to a URL, and interact with elements using the underlying Playwright API. It also shows how to integrate with `robocorp-tasks` and `robocorp-vault` for defining tasks and managing secrets.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}