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.4.0.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.4.0-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: robocorp_browser-2.4.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for robocorp_browser-2.4.0.tar.gz
Algorithm Hash digest
SHA256 a42dfe36ed6c0a725271b982625d9f15acfaedc27c7cd2dab29ee5e46d0f67ff
MD5 a1d70a4248e809c350e48b3cd2d3698f
BLAKE2b-256 b1a695f13ee0b1b4933f9354e8df0d014931822b26ffd7e028ebd8066e49fed4

See more details on using hashes here.

Provenance

The following attestation bundles were made for robocorp_browser-2.4.0.tar.gz:

Publisher: browser_release.yml on robocorp/robocorp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for robocorp_browser-2.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0afc0bd1226ed95ef70754b375b0ec8094aac94c06935c951786eee23c4a15d2
MD5 949826bf9b0b5dfeac43c3841d0fdbb4
BLAKE2b-256 127954d704e70d8afbfddbc27064a65d9e6f7b09c54e48dc4bb43b374cb32acc

See more details on using hashes here.

Provenance

The following attestation bundles were made for robocorp_browser-2.4.0-py3-none-any.whl:

Publisher: browser_release.yml on robocorp/robocorp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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