Skip to main content

Robocorp browser automation library

Project description

robocorp-browser

The robocorp-browser package is a light wrapper for the Playwright -project, with quality-of-life improvements, such as automatic lifecycle management for Playwright objects (meant to be used with robocorp-tasks).

Usage

robocorp-browser

👉 Check that you have added the dependency in your configuration; this library is not part of the robocorp bundle.

  • conda.yaml for automation Task Packages
  • package.yaml for automation Action Packages
  • requirements.txt, pyproject.toml, setup.py|cfg etc. for the rest
from robocorp import browser, vault
from robocorp.tasks import task

@task
def automate_browser():
    """Start a browser to login in the surfed page."""
    # The configuration is used to set the basic `robocorp.browser` settings.
    # It must be called before calling APIs that create Playwright objects.
    browser.configure(
        # NOTE: `screenshot="only-on-failure"` is the default.
        # If this function finishes with an exception, it will make a screenshot and
        #  embed it into the logs.
        screenshot="only-on-failure",

        # By default, `headless` is False, unless running in a Linux container
        #  without a DISPLAY/WAYLAND_DISPLAY environment variable, but it
        #  can also be manually overridden.
        headless=True,  # won't display the browser window

        # Interactions may be run in slow motion (given in milliseconds).
        slowmo=100,
    )

    # The `browser.goto()` call may be used as a shortcut to get the current page and
    #  surf some URL (it may create the browser if not created already).
    browser.goto("https://example.com>")

    _login()  # call the login instructions


def _login():
    # APIs in `robocorp.browser` return the same browser instance, which is
    #  automatically closed when the task finishes.
    page = browser.page()

    # `robocorp.vault` is recommended for managing secrets.
    account = vault.get_secret("default-account")

    # Use the Playwright Browser API as usual to interact with the web elements.
    page.fill('//input[@ng-reflect-name="password"]', account["password"])
    page.click("input:text('Submit')")

🚀 Get started with our template now!

Guides

API Reference

Explore our API for extensive documentation.

Changelog

A list of releases and corresponding changes can be found in the changelog.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robocorp_browser-2.3.5.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

robocorp_browser-2.3.5-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file robocorp_browser-2.3.5.tar.gz.

File metadata

  • Download URL: robocorp_browser-2.3.5.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.12.3 Linux/6.8.0-1021-azure

File hashes

Hashes for robocorp_browser-2.3.5.tar.gz
Algorithm Hash digest
SHA256 126ec9c772aa1ccc102ed9258fb382108f41f2fe30ab30e7fec97c68f3ec9040
MD5 4747d65b4166f2557edeffc09a434d61
BLAKE2b-256 e0b9df10f605aade3d5e98b400e5e93d4903587059ad292148a043f66a605dce

See more details on using hashes here.

File details

Details for the file robocorp_browser-2.3.5-py3-none-any.whl.

File metadata

  • Download URL: robocorp_browser-2.3.5-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.12.3 Linux/6.8.0-1021-azure

File hashes

Hashes for robocorp_browser-2.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f5fa8d8255a25ccab95ecdf8ff3333cc714e3ced841c621b1c2ad5e44c19f9e7
MD5 eaf20e3ae3dbbf78d1c2dc1d4d9d9f41
BLAKE2b-256 74e2ddaadfa993e0b4173c559c3984117f7f2b1c2c385d1f79ca15d95b78e72f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page