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
👉 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file robocorp_browser-2.3.3.tar.gz
.
File metadata
- Download URL: robocorp_browser-2.3.3.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.10.12 Linux/6.5.0-1017-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a1222e3f743ff9669b2b893d34dea6fb8c67ff9e122c13c7623d65cf22aac07 |
|
MD5 | 7a4746c27dbee247bbf745f26272b861 |
|
BLAKE2b-256 | 344bcac8e961cf4d0db6295917d4216c1644c1977753fff77d8694db3850d701 |
Provenance
File details
Details for the file robocorp_browser-2.3.3-py3-none-any.whl
.
File metadata
- Download URL: robocorp_browser-2.3.3-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.10.12 Linux/6.5.0-1017-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0ca8cdac0a8bcfaa3f26bd4c449ab4eff6001babea81f0ea2b23ed0a02a319c |
|
MD5 | 5f9be232f3f3cda1bc8acfeef7e8c6a6 |
|
BLAKE2b-256 | 93a6801e7e8fd2a1274e8fbb3e95b86cb7cc2c3c09564429890b7a1edc7617aa |