robocorp-browser
module robocorp.browser
Source: __init__.py:0
function configure
Source: __init__.py:18
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 areon
,off
, andonly-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
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:
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
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:
function browser
Source: __init__.py:105
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
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
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 theconfigure_context(...)
returned dict. If the context was already previously created the **kwargs passed will be ignored.
function goto
Source: __init__.py:173
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
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
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