robocorp-browser


Namerobocorp-browser JSON
Version 2.3.3 PyPI version JSON
download
home_pagehttps://github.com/robocorp/robocorp/
SummaryRobocorp browser automation library
upload_time2024-04-08 10:14:01
maintainerNone
docs_urlNone
authorFabio Z.
requires_python<4.0,>=3.9
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # robocorp-browser

The **robocorp-browser** package is a light wrapper for the [Playwright](https://playwright.dev/python/) -project, with quality-of-life improvements, such as automatic lifecycle management for Playwright objects (meant to be used with **robocorp-tasks**).

## Usage

[![`robocorp-browser`](https://img.shields.io/pypi/v/robocorp-browser?label=robocorp-browser)](https://pypi.org/project/robocorp-browser/)

> 👉 Check that you have added the dependency in your configuration; this library is not part of the [**robocorp**](https://pypi.org/project/robocorp/) bundle.
> - _conda.yaml_ for automation [Task Packages](https://robocorp.com/docs/robot-structure)
> - _package.yaml_ for automation Action Packages
> - _requirements.txt_, _pyproject.toml_, _setup.py|cfg_ etc. for the rest

```python
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](https://robocorp.com/portal/robot/robocorp/template-python-browser) now!

## Guides

- [Browser configuration](https://github.com/robocorp/robocorp/blob/master/browser/docs/guides/00-configuration.md)
- [Persistent Context](https://github.com/robocorp/robocorp/blob/master/browser/docs/guides/01-persistent-context.md)

## API Reference

Explore our [API](https://github.com/robocorp/robocorp/blob/master/browser/docs/api/README.md) for extensive documentation.

## Changelog

A list of releases and corresponding changes can be found in the [changelog](https://github.com/robocorp/robocorp/blob/master/browser/docs/CHANGELOG.md).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/robocorp/robocorp/",
    "name": "robocorp-browser",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Fabio Z.",
    "author_email": "fabio@robocorp.com",
    "download_url": "https://files.pythonhosted.org/packages/34/4b/cac8e961cf4d0db6295917d4216c1644c1977753fff77d8694db3850d701/robocorp_browser-2.3.3.tar.gz",
    "platform": null,
    "description": "# robocorp-browser\n\nThe **robocorp-browser** package is a light wrapper for the [Playwright](https://playwright.dev/python/) -project, with quality-of-life improvements, such as automatic lifecycle management for Playwright objects (meant to be used with **robocorp-tasks**).\n\n## Usage\n\n[![`robocorp-browser`](https://img.shields.io/pypi/v/robocorp-browser?label=robocorp-browser)](https://pypi.org/project/robocorp-browser/)\n\n> \ud83d\udc49 Check that you have added the dependency in your configuration; this library is not part of the [**robocorp**](https://pypi.org/project/robocorp/) bundle.\n> - _conda.yaml_ for automation [Task Packages](https://robocorp.com/docs/robot-structure)\n> - _package.yaml_ for automation Action Packages\n> - _requirements.txt_, _pyproject.toml_, _setup.py|cfg_ etc. for the rest\n\n```python\nfrom robocorp import browser, vault\nfrom robocorp.tasks import task\n\n@task\ndef automate_browser():\n    \"\"\"Start a browser to login in the surfed page.\"\"\"\n    # The configuration is used to set the basic `robocorp.browser` settings.\n    # It must be called before calling APIs that create Playwright objects.\n    browser.configure(\n        # NOTE: `screenshot=\"only-on-failure\"` is the default.\n        # If this function finishes with an exception, it will make a screenshot and\n        #  embed it into the logs.\n        screenshot=\"only-on-failure\",\n\n        # By default, `headless` is False, unless running in a Linux container\n        #  without a DISPLAY/WAYLAND_DISPLAY environment variable, but it\n        #  can also be manually overridden.\n        headless=True,  # won't display the browser window\n\n        # Interactions may be run in slow motion (given in milliseconds).\n        slowmo=100,\n    )\n\n    # The `browser.goto()` call may be used as a shortcut to get the current page and\n    #  surf some URL (it may create the browser if not created already).\n    browser.goto(\"https://example.com>\")\n\n    _login()  # call the login instructions\n\n\ndef _login():\n    # APIs in `robocorp.browser` return the same browser instance, which is\n    #  automatically closed when the task finishes.\n    page = browser.page()\n\n    # `robocorp.vault` is recommended for managing secrets.\n    account = vault.get_secret(\"default-account\")\n\n    # Use the Playwright Browser API as usual to interact with the web elements.\n    page.fill('//input[@ng-reflect-name=\"password\"]', account[\"password\"])\n    page.click(\"input:text('Submit')\")\n```\n\n\ud83d\ude80 Get started with our [template](https://robocorp.com/portal/robot/robocorp/template-python-browser) now!\n\n## Guides\n\n- [Browser configuration](https://github.com/robocorp/robocorp/blob/master/browser/docs/guides/00-configuration.md)\n- [Persistent Context](https://github.com/robocorp/robocorp/blob/master/browser/docs/guides/01-persistent-context.md)\n\n## API Reference\n\nExplore our [API](https://github.com/robocorp/robocorp/blob/master/browser/docs/api/README.md) for extensive documentation.\n\n## Changelog\n\nA list of releases and corresponding changes can be found in the [changelog](https://github.com/robocorp/robocorp/blob/master/browser/docs/CHANGELOG.md).\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Robocorp browser automation library",
    "version": "2.3.3",
    "project_urls": {
        "Homepage": "https://github.com/robocorp/robocorp/",
        "Repository": "https://github.com/robocorp/robocorp/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "93a6801e7e8fd2a1274e8fbb3e95b86cb7cc2c3c09564429890b7a1edc7617aa",
                "md5": "5f9be232f3f3cda1bc8acfeef7e8c6a6",
                "sha256": "c0ca8cdac0a8bcfaa3f26bd4c449ab4eff6001babea81f0ea2b23ed0a02a319c"
            },
            "downloads": -1,
            "filename": "robocorp_browser-2.3.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5f9be232f3f3cda1bc8acfeef7e8c6a6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 14194,
            "upload_time": "2024-04-08T10:14:00",
            "upload_time_iso_8601": "2024-04-08T10:14:00.360768Z",
            "url": "https://files.pythonhosted.org/packages/93/a6/801e7e8fd2a1274e8fbb3e95b86cb7cc2c3c09564429890b7a1edc7617aa/robocorp_browser-2.3.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "344bcac8e961cf4d0db6295917d4216c1644c1977753fff77d8694db3850d701",
                "md5": "7a4746c27dbee247bbf745f26272b861",
                "sha256": "4a1222e3f743ff9669b2b893d34dea6fb8c67ff9e122c13c7623d65cf22aac07"
            },
            "downloads": -1,
            "filename": "robocorp_browser-2.3.3.tar.gz",
            "has_sig": false,
            "md5_digest": "7a4746c27dbee247bbf745f26272b861",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 12098,
            "upload_time": "2024-04-08T10:14:01",
            "upload_time_iso_8601": "2024-04-08T10:14:01.867475Z",
            "url": "https://files.pythonhosted.org/packages/34/4b/cac8e961cf4d0db6295917d4216c1644c1977753fff77d8694db3850d701/robocorp_browser-2.3.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-08 10:14:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "robocorp",
    "github_project": "robocorp",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "robocorp-browser"
}
        
Elapsed time: 0.40744s