robocorp-browser

module robocorp.browser

Source: __init__.py:0


function configure

Source: __init__.py:18

configure(**kwargs) โ†’ None

May be called before any other method to configure the browser settings.

Calling this method is optional (if not called a default configuration will be used -- note that calling this method after the browser is already initialized will have no effect).

Args:

  • browser_engine: Browser engine which should be used (default: Chromium)
  • headless: If set to False the browser UI will be shown. If set to True the browser UI will be kept hidden. If unset or set to None it'll show the browser UI only if a debugger is detected.
  • slowmo: Run interactions in slow motion.
  • screenshot: Whether to automatically capture a screenshot after each task. Options are on, off, and only-on-failure (default).
  • viewport_size: Size to be set for the viewport. Specified as tuple(width, height).

Note:

See also: robocorp.browser.configure_context to change other arguments related to the browser context creation.


function configure_context

Source: __init__.py:55

configure_context(**kwargs) โ†’ None

While the most common configurations may be configured through configure, not all arguments passed to playwright.Browser.new_context are covered.

For cases where different context keyword arguments are needed it's possible to use this method to customize the keyword arguments passed to playwright.Browser.new_context.

Example:

from robocorp import browser browser.configure_context(ignore_https_errors = True)

Note:

The changes done persist through the full session, so, new tasks which create a browser context will also get the configuration changes. If the change should not be used across tasks it's possible to call robocorp.browser.context(...) with the required arguments directly.


function page

Source: __init__.py:83

page() โ†’ Page

Provides a managed instance of the browser page to interact with.

Returns: The browser page to interact with.

Note that after a page is created, the same page is returned until the current task finishes or the page is closed.

If a new page is required without closing the current page use:

from robocorp import browser page = browser.context().new_page()

function browser

Source: __init__.py:105

browser() โ†’ Browser

Provides a managed instance of the browser to interact with.

Returns: The browser which should be interacted with.

If no browser is created yet one is created and the same one is returned on new invocations.

To customize the browser use the configure method (prior to calling this method).

Note that the returned browser must not be closed. It will be automatically closed when the task run session finishes.


function playwright

Source: __init__.py:126

playwright() โ†’ Playwright

Provides a managed instance of playwright to interact with.

Returns: The playwright instance to interact with.

If no playwright instance is created yet one is created and the same one is returned on new invocations.

To customize it use the configure method (prior to calling this method).

Note that the returned instance must not be closed. It will be automatically closed when the task run session finishes.


function context

Source: __init__.py:147

context(**kwargs) โ†’ BrowserContext

Provides a managed instance of the browser context to interact with.

Returns: The browser context instance to interact with.

If no browser context instance is created yet one is created and the same one is returned on new invocations.

Note that the returned instance must not be closed. It will be automatically closed when the task run session finishes.

Note:

If the context is not created it's possible to customize the context arguments through the kwargs provided, by using the configure(...) method or by editing the configure_context(...) returned dict. If the context was already previously created the **kwargs passed will be ignored.


function goto

Source: __init__.py:173

goto(url: str) โ†’ Page

Changes the url of the current page (creating a page if needed).

Args:

  • url: Navigates to the provided URL.

Returns: The page instance managed by the robocorp.tasks framework(it will be automatically closed when the task finishes).


function screenshot

Source: __init__.py:189

screenshot( element: Optional[Page, ElementHandle, Locator] = None, timeout: int = 5000, image_type: Literal['png', 'jpeg'] = 'png', log_level: Literal['INFO', 'WARN', 'ERROR'] = 'INFO' ) โ†’ bytes

Takes a screenshot of the given page/element/locator and saves it to the log. If no element is provided the screenshot will target the current page.

Note: the element.screenshot can be used if the screenshot is not expected to be added to the log.

Args:

  • element: The page/element/locator which should have its screenshot taken. If notgiven the managed page instance will be used.

Returns: The bytes from the screenshot.


function install

Source: __init__.py:232

install(browser_engine: BrowserEngine)

Downloads and installs the given browser engine.

Note: Google Chrome or Microsoft Edge installations will be installed at the default global location of your operating system overriding your current browser installation.

Args:

  • browser_engine: Browser engine which should be installed

enum BrowserEngine

Source: _browser_engines.py:14

Valid browser engines for Playwright.

Values

  • CHROMIUM = chromium
  • CHROME = chrome
  • CHROME_BETA = chrome-beta
  • MSEDGE = msedge
  • MSEDGE_BETA = msedge-beta
  • MSEDGE_DEV = msedge-dev
  • FIREFOX = firefox
  • WEBKIT = webkit