F(x)

Updated at:

create

create(url, wait=True, timeout=100, chrome_path=None)

Description

Opens a specified URL in a new Chrome tab.

Important

For information on Chrome's Incognito mode, see Running in Incognito mode.

Parameters

url<str> The URL to open.

wait<bool> Whether to wait for the page to finish loading.

timeout<int> The page load timeout in seconds. Default: 100.

chrome_path<str> The path to chrome.exe.

  • None: Automatically searches the %ProgramFiles% and %ProgramFiles(x86)% directories.

  • The value must be the full path to chrome.exe, such as C:\Program Files\Google\Chrome\Application\chrome.exe.

Return value

Returns a ChromeTab object<ChromeTab>.

Example- rpa.app.chrome.create-

# Note: Before using this method, ensure that the Alibaba Cloud RPA extension for Chrome is installed and enabled.
page = rpa.app.chrome.create('www.aliyun.com')

catch

catch(name, mode='title', pattern='contain', timeout=10)

Description

Catches an already opened page.

Parameters

name<str> The title or URL of the page.

mode<str> The match mode.

Options:

  • title: Matches by page title.

  • url: Matches by page URL.

pattern<str> The match pattern.

Options:

  • equal: exact match

  • contain: contains match

  • regular: regular expression match

timeout<int> The maximum time in seconds to wait for the page.

Return value

Returns a ChromeTab object<ChromeTab>.

Important

Returns the first matching page.

Example- rpa.app.chrome.catch-

# Note: Ensure that the Alibaba Cloud RPA extension for Chrome is installed and enabled, and the target web page is already open.
# By default, this performs a 'contains match' on the page title:
page = rpa.app.chrome.catch('Alibaba Cloud')

# Title - regular expression match
page = rpa.app.chrome.catch(".*", mode="title", pattern="regular")

# URL - exact match
page = rpa.app.chrome.catch("baidu", mode="url", pattern="equal")

# URL - contains match
page = rpa.app.chrome.catch("baidu", mode="url", pattern="contain")

# URL - regular expression match
page = rpa.app.chrome.catch(".*m/$", mode="url", pattern="regular")

catch_specific_pages

catch_specific_pages(name, mode='title', pattern='contain')

Description

Catches all pages that match the specified criteria.

Important

To get a single page, use catch.

Parameters

name<str> The title or URL of the page.

mode<str> The match mode.

Options:

  • title: Matches by page title.

  • url: Matches by page URL.

pattern<str> The match pattern.

Options:

  • equal: exact match

  • contain: contains match

  • regular: regular expression match

Return value

Returns a list of ChromeTab objects<list>.

Example- rpa.app.chrome.catch_specific_pages-

# Note: Ensure that the Alibaba Cloud RPA extension for Chrome is installed and enabled, and at least one matching web page is open.
# By default, this performs a 'contains match' on the page title:
page_list = rpa.app.chrome.catch_specific_pages('Alibaba Cloud')

# Title - regular expression match
page_list = rpa.app.chrome.catch_specific_pages(".*", mode="title", pattern="regular")

# URL - exact match
page_list = rpa.app.chrome.catch_specific_pages("baidu", mode="url", pattern="equal")

# URL - contains match
page_list = rpa.app.chrome.catch_specific_pages("baidu", mode="url", pattern="contain")

# URL - regular expression match
page_list = rpa.app.chrome.catch_specific_pages(".*m/$", mode="url", pattern="regular")

catch_all_pages

catch_all_pages()

Description

Returns all open pages.

Example- rpa.app.chrome.catch_all_pages-

# Note: Before using this method, ensure that the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# Example:
page_list = rpa.app.chrome.catch_all_pages()

catch_activated_pages

catch_activated_pages()

Description

Returns all active pages.

Important

To get a new page that opens from an existing one (e.g., a pop-up):

  • (Recommended) Use attr to get the target URL (for example, from the href attribute of a control), and then use create to open it.

  • Method 2: If the URL is unavailable (for example, if the page uses JavaScript for redirection), click the control and then do one of the following:

    • Use catch to capture the new page based on its title or URL characteristics. This ensures the page is fully loaded and ready for other actions.

    • If the title or URL of the new page is dynamic and lacks suitable characteristics, use catch_activated_pages to get the currently active page. Add time.sleep() to your process code to ensure the new page has fully loaded.

Example- rpa.app.chrome.catch_activated_pages-

# Note: Before using this method, ensure that the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# If multiple Chrome browser processes are running, this method returns the active tab from each process.
page_list = rpa.app.chrome.catch_activated_pages()

close_all

close_all(script_timeout=10)

Description

Closes all open pages.

Parameters

script_timeout<float> The script execution timeout in seconds. Default: 10.

Example- rpa.app.chrome.close_all-

# Note: Before using this method, ensure that the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# Example:
rpa.app.chrome.close_all(script_timeout=10)

maximize

maximize()

Description

Maximizes the browser window.

Example- rpa.app.chrome.maximize-

# Note: Before using this method, ensure that the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# If multiple Chrome browser windows are open, this method maximizes only one of them.
# Example:
rpa.app.chrome.maximize()

minimize

minimize()

Description

Minimizes the browser window.

Example- rpa.app.chrome.minimize-

# Note: Before using this method, ensure that the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# If multiple Chrome browser windows are open, this method minimizes only one of them.
# Example:
rpa.app.chrome.minimize()

restore

restore()

Description

Restores the browser window to its previous size and position.

Example- rpa.app.chrome.restore-

# Note: Before using this method, ensure that the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# If multiple Chrome browser windows are open, this method restores only one of them.
# Example:
rpa.app.chrome.restore()

catch_from_element_name

catch_from_element_name(element)

Description

Catches a page using an element name.

Parameters

element<str> The element name.

Return value

Returns a ChromeTab object.

Example- rpa.app.chrome.catch_from_element_name-

# Note: Before using this method, ensure that the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# Example:
page = rpa.app.chrome.catch_from_element_name('Baidu search box')
page.input_text('Baidu search box', 'Alibaba Cloud')

get_cookies

get_cookies(url=None, domain=None, name=None)

Description

Gets cookies that match the specified filters.

Parameters

url<str> Filters for cookies that match the given URL.

domain<str> Filters for cookies whose domain matches or is a subdomain of the specified domain.

name<str> Filters cookies by name.

Return value

Returns a list of all cookies that match the filters<list>.

Example- rpa.app.chrome.get_cookies-

# Note: Before using this method, ensure that the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# The url parameter must be a complete URL that includes the protocol (e.g., 'https://').
# Example:
cookies = rpa.app.chrome.get_cookies(url='https://www.aliyun.com')

remove_cookie

remove_cookie(url, name)

Description

Deletes a cookie.

Parameters

url<str> The URL associated with the cookie.

name<str> The name of the cookie to delete.

Example- rpa.app.chrome.remove_cookie-

# Note: Before using this method, ensure that the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# The url parameter must be a complete URL that includes the protocol (e.g., 'https://').
# Example:
rpa.app.chrome.remove_cookie('https://www.baidu.com', 'domain')

set_cookie

set_cookie(url, name, domain=None, value=None, path=None, secure=False, http_only=False, expiration_date=None)

Description

Sets a cookie.

Parameters

url<str> The URL to associate with the cookie.

name<str> The name of the cookie.

domain<str> The domain of the cookie. If omitted, the cookie becomes a host-only cookie.

value<str> The value of the cookie. If omitted, the value defaults to an empty string.

path<str> The path of the cookie. Defaults to the path portion of the url parameter.

secure<bool> Whether to mark the cookie as secure.

http_only<bool> Whether to mark the cookie as HTTP-only.

expiration_date<str> The expiration date of the cookie.

Example- rpa.app.chrome.set_cookie-

# Note: Before using this method, ensure that the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# The url parameter must be a complete URL that includes the protocol (e.g., 'https://').
# Example:
rpa.app.chrome.set_cookie('https://www.baidu.com', 'rpa_test', value='Alibaba Cloud RPA test_www.aliyun.com')

network_capture_stop

network_capture_stop(capture_key)

Description

Stops network request capture.

Parameters

capture_key<str> The capture key for the network request capture.

Return value

None

Example- rpa.app.chrome.network_capture_stop-

# Note: This method requires the Alibaba Cloud RPA extension for Chrome to be installed and enabled.
# This method must be called on a ChromeTab instance.
# The following shows an example:
# Open the Alibaba Cloud page in Google Chrome.
page = rpa.app.chrome.create('www.aliyun.com')
# Start network request capture.
capture_key = page.network_capture_start(url='', use_regular=False, capture_types=[])
# Reload the page.
page.reload()
# Get the network request capture result.
web_respond_body = rpa.app.chrome.get_network_capture_result(capture_key)
# Stop network request capture.
rpa.app.chrome.network_capture_stop(capture_key)
# Log the information.
rpa.console.logger.info(web_respond_body)

get_network_capture_result

get_network_capture_result(capture_key)

Description

Gets the result of a network request capture.

Parameters

capture_key<str> The capture key for the network request capture.

Return value

Returns a JSON string that contains the network request capture result<string>.

Example- rpa.app.chrome.get_network_capture_result-

# Note: This method requires the Alibaba Cloud RPA extension for Chrome to be installed and enabled.
# This method must be called on a ChromeTab instance.
# The following shows an example:
# Open the Alibaba Cloud page in Google Chrome.
page = rpa.app.chrome.create('www.aliyun.com')
# Start network request capture.
capture_key = page.network_capture_start(url='', use_regular=False, capture_types=[])
# Reload the page.
page.reload()
# Get the network request capture result.
web_respond_body = rpa.app.chrome.get_network_capture_result(capture_key)
# Stop network request capture.
rpa.app.chrome.network_capture_stop(capture_key)
# Log the information.
rpa.console.logger.info(web_respond_body)