EdgeTab

Updated at:

Close

close()

Description

Close the browser object.

Example: rpa.app.edge.EdgeTab.close

# This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# Call this method on an EdgeTab instance.
# Usage example:
page = rpa.app.edge.create('www.aliyun.com')
page.close()

Navigate

navigate(url, wait=True, timeout=100)

Description

Follow the specified link.

Parameters

url<str> The URL to open.

waitboolean Determines whether to wait for the loading process to complete.

timeout<int> The timeout period in seconds. Default: 100.

Code sample - rpa.app.edge.EdgeTab.navigate

# This method requires the Aliyun RPA Edge extension to be installed and enabled.
# You must call this method on an EdgeTab instance object.
# Example:
url = 'www.aliyun.com'
page = rpa.app.edge.create(url)
page.navigate('help.aliyun.com/document_detail/175379.html')

Back

back(wait=True, timeout=100)

Method Description

browser back navigation

Parameters

wait<bool> Whether to wait for the loading to complete.

timeout<int>The timeout in seconds. The default is 100.

Sample code: rpa.app.edge.EdgeTab.back

# Requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# Call this method on an EdgeTab instance object.
# Usage example:
url = 'www.aliyun.com'
page = rpa.app.edge.create(url)
page.navigate('help.aliyun.com/document_detail/175379.html')
page.back()

Foreword

forward(wait=True, timeout=100)

Description

Forward

Parameters

wait<bool> Specifies whether to wait for the loading process to complete.

timeout<int>The timeout in seconds. The default is 100.

Example: rpa.app.edge.EdgeTab.forward

# Note: Before using this method, ensure the Alibaba Cloud RPA Edge extension is installed and enabled.
# You must call this method on an EdgeTab instance object.
# Usage example:
url = 'www.aliyun.com'
page = rpa.app.edge.create(url)
page.navigate('help.aliyun.com/document_detail/175379.html')
page.back()
page.forward()

Activate

activate()

Description

Activation page

Code sample: rpa.app.edge.EdgeTab.activate

# Note: This method requires the Aliyun RPA Edge extension to be installed and enabled.
# Call this method on an EdgeTab instance.
# Example:
url = 'www.aliyun.com'
page = rpa.app.edge.create(url)
page.activate()

URL

URL()

Description

Get the URL

Return value

The return url<str>

Code sample: rpa.app.edge.EdgeTab.url

# This method requires the Aliyun RPA Edge extension to be installed and enabled.
# Call this method on an EdgeTab instance object.
# Example:
page = rpa.app.edge.create('www.aliyun.com')
url = page.url()

Auto scaling

title()

Description

Getting the title

Return value

Returns the title <string>.

Code example: rpa.app.edge.EdgeTab.title

# Note: This method requires the Aliyun RPA extension for Edge to be installed and enabled.
# This method must be called on an EdgeTab instance object.
# Usage example:
page = rpa.app.edge.create('www.aliyun.com')
title= page.title()

Reload

reload(bypass_cache=False, wait=True, timeout=100)

Description

Refresh the page

Parameter

bypass_cache<bool> Whether to bypass the cache.

wait<boolean> Determines whether to wait for the load to complete.

timeout<int>The timeout in seconds. Default: 100s.

Code Sample: rpa.app.edge.EdgeTab.reload

# Requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# Call this method on an EdgeTab instance.
# Example:
page = rpa.app.edge.create('www.aliyun.com')
page.reload()

get_cookie

get_cookie()

Description

Get all cookies for the current website.

Return value

Returns all cookies for the current website<list>

Code sample: rpa.app.edge.EdgeTab.get_cookie

# Note: This method requires the Aliyun RPA Edge extension to be installed and enabled.
# This method must be called on an EdgeTab instance object.
# Example:
page = rpa.app.edge.create('www.aliyun.com')
cookie = page.get_cookie()

wait_load_completed

wait_load_completed(timeout=100)

Description

Wait for the page to load.

Parameters

timeout<int>The timeout in seconds. Default: 100 s.

Code sample: rpa.app.edge.EdgeTab.wait_load_completed

# Note: Before using this method, ensure the Alibaba Cloud RPA Edge extension is installed and enabled.
# You must call this method on an EdgeTab instance.
# Example:
page = rpa.app.edge.create('www.aliyun.com')
page.wait_load_completed()

Copy

copy()

Description

Copy from the current page.

Return value

Indicates whether the operation was successful.<boolean>

Code sample: rpa.app.edge.EdgeTab.copy

# Notes:
# 1. Ensure the Alibaba Cloud RPA Edge extension is installed and enabled.
# 2. You must select the content to copy before calling this method, as it only performs the copy operation.
# 3. This method writes the content to the system clipboard.
# The following example selects text by double-clicking a cell, then copies it:
page = rpa.app.edge.create('https://help.aliyun.com/document_detail/175379.html')
page.double_click('queryClientViews-edge')
page.copy()

Paste

paste()

Description

Paste on the current page.

Return value

Indicates if the operation succeeded<bool>

Example: rpa.app.edge.EdgeTab.paste

# Notes:
# 1. Ensure the Alibaba Cloud RPA Edge extension is installed and enabled.
# 2. This method only performs a paste operation. Focus the target area before calling this method.
# 3. This method pastes the latest content from the clipboard into the target area.
# The following code sample copies a cell's content, clicks the search box, and pastes it:
page = rpa.app.edge.create('https://help.aliyun.com/document_detail/175379.html')
page.double_click('queryClientViews-edge')
page.copy()
page.click('document_search_box-edge')
page.paste()

Cut

cut()

Description

Cuts from the current page.

Return value

Indicates whether the operation was successful.<bool>

Code sample: rpa.app.edge.EdgeTab.cut

# Notes:
# 1. Before you use this method, make sure that the Alibaba Cloud RPA extension for Edge is installed and enabled.
# 2. This method only executes the cut command. You must select the content that you want to cut by using other methods before you run this method. If the content cannot be cut, this action has no effect.
# 3. This method writes the content to the system clipboard.
# The following code provides an example. In this example, you must first manually open the Baidu homepage and enter any content in the input box.
# The program then double-clicks the input box to select the text and performs the cut action:
page = rpa.app.edge.catch('www.baidu.com',mode='url')
page.double_click('Baidu_input_box-edge')
page.cut()

execute_js

execute_js(code, element=None, index=1, timeout=10)

Description

Execute JavaScript code

Parameters

code<str> The JavaScript code.

element<str>The element that determines the JS execution domain for cross-domain operations.

index<int> The index of the control, used if multiple are found.

timeout<int>Timeout period.

Return value

Returns the execution result in JSON format<string>

Code example: rpa.app.edge.EdgeTab.execute_js

# This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# You must call this method on an EdgeTab instance object.
# Example:
js_code = """
    function test(){ 
    var div1 = document.getElementById("su").getAttribute('%s');
    return(div1) 
    } ; 
result = test() ; 
console.log(result) ; 
alert(result);
return result;
"""%'value'

url = 'www.baidu.com'
page = rpa.app.edge.create(url)

value = page.execute_js(js_code)
print(value)

Table

table(value, type='index', return_type='text', parent_element=None)

Method

Retrieve a table

Parameters

type<str> The match type.

Options:

  • index: Matches by index.

  • text: Matches by text content.

  • html: Matches by HTML content.

return_type<str>return type

Optional:

  • text: Specifies plain text.

  • html: Specifies html.

Return value

Returns a two-dimensional array or an HTML <list> for the matched table.

Example: RPA.app.edge.EdgeTab.table-

# Notes:
# 1. To use this method, you must install and enable the Alibaba Cloud RPA extension for Edge.
# 2. This method retrieves a standard HTML <table> from a web page by using its 1-based index or a regular expression.
# The following code retrieves the first table from the web page, which is the first <table> tag in the HTML source:
page = rpa.app.edge.create('https://help.aliyun.com/document_detail/175379.html')
table_data = page.table(1)

Scroll

scroll(height=0, element=None, index=1, parent_element=None, timeout=10, direction='top')

Description

Scroll the page.

Parameters

height<int> Scrolls by a specified amount. If omitted, scrolls to the bottom of the page.

control<str>The UI control

index<int>The index of the control to use when more than one is found.

parent_element<Element>The parent element.

timeout<int> The timeout period.

direction<str>The direction of the scrollbar.

Optional:

  • left: Scrolls left.

  • down: Scrolls down.

Example: rpa.app.edge.EdgeTab.scroll

# Notes:
# 1. Ensure the Alibaba Cloud RPA extension for Edge is installed and enabled.
# 2. If no parameters are passed, or if `height` is set to 0, the method scrolls to the bottom of the page.
# Example:
page = rpa.app.edge.create('https://help.aliyun.com/document_detail/175379.html')
page.scroll()
# To scroll a specific element, such as a list pane, pass parameters like `height` and `element`.
page.scroll(height=200, element='scrollable_list_pane', index=1, parent_element=None, timeout=10, direction='top')
Important

The control to record is the scrollable list.scroll_1

get_element_by_name

get_element_by_name(element, index=1, parent_element=None, timeout=10)

Description

GetObject

Parameters

element<str>A control.

index<int> The index of the control to use when there are multiple matches.

parent element<Element>The parent element.

timeout<int>The timeout period.

Return value

Returns a control object<Element>.

Example: rpa.app.edge.EdgeTab.get_element_by_name

# Notes:
# 1. Ensure the Alibaba Cloud RPA Edge extension is installed and enabled.
# 2. Before you start, use capture control to capture page elements.
# Usage example:
url = 'https://www.baidu.com/'
page = rpa.app.edge.create(url)
element = page.get_element_by_name('baidu_search_button-edge')
text = element.text()

get_element_by_css

get_element_by_css(css, index=1, parent_element=None, timeout=10)

Description

Select a control using a CSS expression.

Parameters

CSS<str>CSS expression

index<int> The index of the control to select when multiple are found.

parent_element<str> The parent element

timeout<int>The timeout duration.

Return value

Returns an <Element> object.

Example: rpa.app.edge.EdgeTab.get_element_by_css

# Notes:
# 1. Ensure the Alibaba Cloud RPA extension for Edge is installed and enabled.
# 2. This method locates an element using a standard CSS selector.
# Usage example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.edge.create(url)
css_selector = "span.lake-fontsize-11" # Selects a span element with the class lake-fontsize-11.
element = page.get_element_by_css(css_selector)
text = element.text()

Count

count(element, parent_element=None)

Description

Get the number of controls.

Parameters

element<str> The control.

parent element<Element>The parent element.

Code sample: rpa.app.edge.EdgeTab.count

# Notes:
# 1. Ensure the Alibaba Cloud RPA extension for Edge is installed and enabled.
# 2. Commonly used to count controls captured with the "Capture Similar Controls" feature.
# Code example:
url = 'www.aliyun.com'
page = rpa.app.edge.create(url)
element_count = page.count('Sign in button-edge')

wait_loaded

wait_loaded(element, index=1, parent_element=None, timeout=10, ignore_error=True)

Method

Loading the control.

Parameters

element<str>The UI element.

index<int>The index of the control to select when multiple controls match.

parent_element<Element>Parent element.

timeout<int>The timeout duration.

ignore_error<bool> Specifies whether to ignore errors.

Example: rpa.app.edge.EdgeTab.wait_loaded

# Notes:
# 1. Ensure the Alibaba Cloud RPA extension for Edge is installed and enabled.
# 2. Ensure the page element is recorded using capture control.
# Example:
page = rpa.app.edge.create('www.taobao.com')
flag = page.wait_loaded('Taobao logo')

wait_disappear

wait_disappear(element, index=1, parent_element=None, timeout=10)

Description

Wait for the control to disappear

Parameters

element<str>A control.

index<int> The index of the control to use if multiple are found.

parent_element<str> The parent control object.

timeout<int>The timeout duration.

Code sample: rpa.app.edge.EdgeTab.wait_disappear

# Notes:
# 1. Ensure the Alibaba Cloud RPA extension for Edge is installed and enabled.
# 2. Ensure the page element is captured first using control capture.
# Usage example:
page = rpa.app.edge.create('www.taobao.com')
page.wait_disappear('Taobao logo')

handle_javascript_dialog

handle_javascript_dialog(value='ok', text=None)

Description

Handling JavaScript pop-ups

Parameters

value<str> The action to perform on the dialog.

Optional:

  • ok: Fires when a user clicks OK.

  • cancel: Fires when a user clicks Cancel.

text<str> The text entered in the pop-up box.

Example: rpa.app.edge.EdgeTab.handle_javascript_dialog

# Notes:
# 1. Ensure the Alibaba Cloud RPA extension for Edge is installed and enabled.
# Example:
url = 'www.baidu.com'
page = rpa.app.edge.create(url)
page.execute_js('alert("Alibaba Cloud RPA_TEST")')
page.handle_javascript_dialog()

Click

click(element, index=1, parent_element=None, simulate=True, button='left', offset_x=0, offset_y=0, move_mode="without-track", speed_mode="uniform", timeout=10)

Description

Click

Parameters

element<str> The control

index<int> The index of the control to select when multiple matches are found.

parent_element<str>The parent control object.

simulate<bool>Specifies whether to simulate a click.

button<str> The mouse button.

Options:

  • Left: left button

  • Right: right button

offset_x<int> The horizontal offset.

offset_y<int>The vertical offset.

move_mode<str>Specifies the mouse movement mode when clicking. This parameter applies only when simulate=True.

Options:

  • without-track: The mouse instantly moves to the control and clicks.

  • with-track: The mouse moves along a simulated path to the control and clicks.

speed_mode<str>The speed mode for mouse movement. This parameter takes effect only when simulate=True and move_mode=with-track.

  • Uniform motion

timeout<int>The timeout period.

Code sample: RPA.app.Edge.EdgeTab.click

# Notes:
# 1. Ensure the Alibaba Cloud RPA extension for Edge is installed and enabled.
# 2. Before using this method, ensure the page element has been recorded using the capture control feature.
# 3. When simulate=True, the method simulates a mouse click. The target page element must be in the visible area.
# 4. When simulate=False, the method sends a click command directly to the element.
# Example:
url = 'www.aliyun.com'
page = rpa.app.edge.create(url)
page.click('login_button-edge')

(Deprecated) input_text

input_text(element, value, index=1, parent_element=None, simulate=True, replace=True, sent_raw=False, wait_mili_seconds=20, timeout=10)

Description

Enters text into an element.

Warning
  1. For client version 4.10.3.1033 and later, we recommend using input_text_simulated or input_text_directed.

  2. This method remains functional and does not affect existing automated processes.

Parameters

element<str> The identifier for the element.

value<str> The text to enter.

index<int> If multiple elements are matched, this parameter specifies the index of the element to use.

parent_element<str> A parent element object to narrow the search for the target element.

simulate<bool> Specifies whether to use simulated input.

replace<bool> Specifies whether to clear the element's existing content before entering text.

sent_raw<bool> Specifies whether to send raw keystrokes. This parameter is effective only in non-simulated mode.

wait_mili_seconds<int> The delay between each character input, in milliseconds. This parameter applies only to simulated input. The default value is 20, and the maximum is 100. A high value may cause a timeout.

timeout<int> The maximum time to wait for the element to be found, in seconds.

Code Sample- rpa.app.edge.EdgeTab.input_text-

# Notes:
# 1. This method requires the Aliyun RPA extension for Edge to be installed and enabled.
# 2. Before use, ensure the page element has been captured.
# Usage example:
url = 'www.aliyun.com'
page = rpa.app.edge.create(url)
page.input_text('search-input','RPA')

input_text_simulated

input_text_simulated(element, value, index=1, mode = 'native', parent_element=None, replace=True, keystroke_interval=20, timeout=10)

Description

Simulates typing text into an element.

Note

This feature is available in client version 4.10.3.1033 and later.

Parameters

element<str> The name of the element.

value<str> The text to input.

index<int> The index of the element to use if multiple elements are matched.

mode<str> The input mode. Valid values are native, cdp, and driver.

  • native: Uses the operating system interface to input text.

  • cdp: Uses the browser extension to simulate typing.

  • driver: Uses the driver to simulate keyboard input.

    Important

    For usage limitations, see Driver input limitations.

parent_element<str> The parent element object.

replace<bool> Whether to clear the existing content before inputting text.

keystroke_interval<int> The interval between keystrokes, in milliseconds. The default value is 20, and the maximum is 100. Setting this value too high may cause a timeout.

timeout<int> The timeout for finding the element, in seconds.

Code sample

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, ensure the page element has been captured using the element capture feature.

url = 'www.aliyun.com'
page = rpa.app.edge.create(url)

page.input_text_simulated('search-input', 'Alibaba Cloud RPA')

input_text_directed

input_text_directed(element, value, index=1, parent_element=None, replace=True, timeout=10)

Description

Inputs text by modifying the element's underlying HTML attributes.

Note

This feature is available in client version 4.10.3.1033 and later.

Important
  1. This method is fast, but may not work on all web pages because its success depends on their front-end implementation.

  2. We recommend using input_text_simulated first.

Parameters

element<str> The locator used to find the element.

value<str> The text to enter into the element.

index<int> If the locator matches multiple elements, this parameter specifies which one to use by its 1-based index.

parent_element<str> The locator for a parent element, used to narrow the search for the target element.

replace<bool> If True, clears the element's existing content before entering the new text.

timeout<int> The maximum time in seconds to wait for the element to be found.

Code sample

# Notes:
# 1. Ensure the Alibaba Cloud RPA extension for Edge is installed and enabled.
# 2. Ensure you capture the page element with the element capture feature before calling this function.

url = 'www.aliyun.com'
page = rpa.app.edge.create(url)

page.input_text_directed('search-input','Alibaba Cloud RPA')

input_hotkeys

input_hotkeys(element, value, index=1, parent_element=None, timeout=10)

Description

Sends a hotkey. For details, see input_hotkey Usage and Virtual Key Code List.

Parameters

element<str>The control.

value<str>The virtual key code.

index<int>The control index to use when multiple controls match.

parent_element<str>The parent control object.

timeout<int>The maximum wait time.

download_by_element

download_by_element(path, element, index=1, parent_element=None, wait=True, suffix=None, complete_timeout=120)

Description

Clicks the specified element to download a file and waits for the download to complete. This function first downloads the file to the browser's default location and then automatically moves it to the specified path.

Important

You must disable the "Ask where to save each file before downloading" and "Open Office files in the browser" settings in your browser. If enabled, these settings will interfere with the automated download action.

Configure the settings as shown in the figure below.

image

Parameters

path<str>The destination file path.

element<str>The element to click.

index<int>The index of the element to use when multiple elements are found.

parent_element<Element>The parent element to search within for the target element.

complete_timeout<int>The maximum time, in seconds, to wait for the download to complete.

wait<bool>If True, the function waits for the download to complete. If False, it returns immediately.

suffix<str>Specifies the type of suffix to automatically append to the file name. Valid values are:

  • datetime: Appends the date and time (YYYYMMDDHHmm).

  • date: Appends the date (YYYYMMDD).

Example

# Notes:
# 1. Make sure that the Aliyun RPA extension for Edge is installed and enabled.
# 2. Before use, capture the download button element on the page and verify that the selector is correct.
# Usage example:
url = 'https://www.cninfo.com.cn/new/disclosure/detail?plate=hke&orgId=9900042435&stockCode=09988&announcementId=1209275224'
page = rpa.app.edge.create(url)
download_path = r'D:\Alibaba-SW-Public-Info.pdf'
page.download_by_element(download_path,'Download announcement-edge')

download_by_url

download_by_url(url, path, wait=True, complete_timeout=120)

Description

Downloads a file from a URL to a specified path. This method first saves the file to the browser's default download location and then moves it to the target path. By default, it waits for the download to complete.

Important

This method requires you to disable the 'Ask where to save each file before downloading' and 'Open Office files in the browser' settings in your browser. Otherwise, the download may fail.

The following figure shows how to configure these settings.

image

Parameters

url<str> The URL of the file to download.

path<str> The destination file path.

complete_timeout<int> The maximum time in seconds to wait for the download to complete. This parameter is effective only when wait is set to True.

wait<bool> Specifies whether to wait for the download to complete.

Example

# Notes:
# 1. Make sure that the Aliyun RPA Edge extension is installed and enabled.
# Usage example:
url = 'https://www.cninfo.com.cn'
page = rpa.app.edge.create(url)
download_url = 'https://www.cninfo.com.cn/new/announcement/download?bulletinId=1209275224&announceTime=2021-02-10'
download_path = r'D:\Alibaba-SW.pdf'
page.download_by_url(download_url,download_path)

Upload

upload(element, file, index=1, parent_element=None, timeout=10)

Method

Upload file

Parameters

element<str> control

file<str> The path to the file to upload.

index<int>Specifies the index of the control to use when there are multiple matches.

parent element<str>Specifies the parent element.

timeout<int>The timeout duration.

Code sample: rpa.app.edge.EdgeTab.upload

# Notes:
# 1. Ensure the Alibaba Cloud RPA extension for Edge is installed and enabled.
# 2. Before use, capture the upload button on the page with the capture control feature and verify it is usable.
# Usage example:
url = 'https://duguang.aliyun.com/experience?type=standard&subtype=idcard#intro'
page = rpa.app.edge.create(url)
upload_path = r'D:\2_test_file_archive\OCR_ID_card_recognition.jpg'
page.upload('upload_image-edge', upload_path)

Text

text(element=None, index=1, parent_element=None, timeout=10)

Method description

Get text

Parameters

element<str> The UI control.

index<int> The index of the control, used when multiple controls exist.

parent_element<str>Parent element.

timeout<int>The timeout period.

Return value

Returns text. If no control is specified, it returns all text in the browser.<str>

Sample code: rpa.app.edge.EdgeTab.text

# Notes:
# 1. Ensure the Alibaba Cloud RPA extension for Edge is installed and enabled.
# 2. Before you start, ensure you have captured the page element using the capture control.
# Example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.edge.create(url)
text = page.text(element='Bottom of page - pre-sales consultation-edge')

HTML

html(element=None, index=1, parent_element=None, timeout=10)

Description

Get html

Parameters

element<str> The control

index<int>The index of the control to select if multiple are found.

parent_element<str>The parent element.

timeout<int>The timeout duration.

Return value

Returns the html content of a specified control, or the html content of the entire page if no control is specified.<str>

Example: rpa.app.edge.EdgeTab.html

# Notes:
# 1. Make sure the Alibaba Cloud RPA extension for Microsoft Edge is installed and enabled.
# 2. Before using this method, ensure the page element has been recorded using 'capture control'.
# Usage example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.edge.create(url)
html = page.html('Bottom of page - pre-sales consultation-edge')

Value

value(element, index=1, parent_element=None, timeout=10)

Description

Get the value.

Parameters

control<str> The control.

index<int>The index of the control to use if more than one is found.

parent_element<str> The parent element.

timeout<int>Timeout duration.

Code sample: rpa.app.edge.EdgeTab.value

# Notes:
# 1. Ensure the Alibaba Cloud RPA Edge extension is installed and enabled.
# 2. Before use, ensure the page element has been recorded using control capture.
# Example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.edge.create(url)
value = page.value('Bottom of page - pre-sales consultation-edge')

Option

option(element, text, index=1, parent_element=None, type='match', timeout=10)

Method description

Dropdown list

Parameters

element<str> The control.

text<string> The text for the option.

index<int>The index of the control to use when multiple controls are found.

type<str> The match type.

Optional:

  • match: Fuzzy match

  • full: Exact match

  • regex: Regex match

parent_element<str>The parent element.

timeout<int>The timeout duration.

Code example - rpa.app.edge.EdgeTab.option-

# Notes:
# 1. Ensure the Alibaba Cloud RPA Edge extension is installed and enabled.
# 2. Use capture control to capture the target dropdown element (an HTML <select> tag) from the page.
# 3. Ensure the dropdown contains the target text option.
# Usage example:
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
page = rpa.app.edge.create(url)

page.option('dropdown-edge','00:00--06:00')

get_checked_state

get_checked_state(element, index=1, parent_element=None, timeout=10)

Method description

Get the checked state

Parameters

element<str> Control

index<int> The index of the control to use if multiple are found.

parent_element<str>Parent element

timeout<int>The timeout duration.

Return value

Returns the checked state <bool>

Example: rpa.app.edge.EdgeTab.get_checked_state

# Notes:
# 1. Ensure the Alibaba Cloud RPA extension for Edge is installed and enabled.
# 2. Before you start, ensure you have recorded the page element with capture control.
# Example:
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
page = rpa.app.edge.create(url)
check_state = page.get_checked_state('checkbox-High-speed train-edge')

set_checked_state

set_checked_state(element, value=True, index=1, parent_element=None, timeout=10)

Description

Setting the checked state.

Parameters

element<str> The control.

value<boolean>Set to True to check, or False to uncheck.

index<int> The index of the control to use when multiple are found.

parent_element<str>The parent element.

timeout<int>The timeout duration.

Example: rpa.app.edge.EdgeTab.set_checked_state

# Notes:
# 1. Ensure the Alibaba Cloud RPA extension for Edge is installed and enabled.
# 2. Ensure you have captured the page element using the capture control feature.
# Usage example:
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
page = rpa.app.edge.create(url)
page.set_checked_state('checkbox-bullet_train-edge', value=True)

Attribute

attr(element, attrname, index=1, parent_element=None, timeout=10)

Description

Get Property

Parameters

element<str> A control.

attrname<str>The name of the control.

index<int> The index of the control to use if more than one is found.

parent_element<str>The parent element.

timeout<int>The timeout duration.

Return value

Returns the attribute value <string>

Code sample: rpa.app.edge.EdgeTab.attr

# Notes:
# 1. Ensure the Alibaba Cloud RPA extension for Edge is installed and enabled.
# 2. Before starting, ensure you have captured the page element with the capture control feature.
# Usage example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.edge.create(url)
attribute = page.attr('Sign in button-edge','class')

process_alert

process_alert(option='ok', element=None, simulate=True, index=1, parent_element=None, timeout=10)

Description

Click in the dialog box.

Parameters

value<str> Specifies the action to take on the dialog box.

Options:

  • OK: Fires when the user clicks OK.

  • Cancel: Fires when the user clicks Cancel.

element<str>The element to click (if omitted, defaults to the browser dialog).

simulate<bool> Whether to simulate the action.

index<int>The index of the control to use if multiple are found.

parent_element<Element>The parent element.

timeout<int>Timeout duration.

Example: rpa.app.edge.EdgeTab.process_alert

# Notes:
# 1. Ensure the Alibaba Cloud RPA extension for Edge is installed and enabled.
# 2. This method only handles confirm or alert pop-ups.
# Usage example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.edge.create(url)
page.execute_js('alert("alert")')
page.process_alert()

process_prompt

process_prompt(text, option='ok', element=None, simulate=True, index=1, parent_element=None, timeout=10)

Description

Type into the input box and click.

Parameters

text<string> The input text.

option<str> The action to perform when the input box is clicked.

Optional:

  • ok: The user clicks OK.

  • cancel: The user clicks Cancel.

element<str>The control to click. If this parameter is omitted, the action is performed on the browser's dialog box.

simulate<bool> Whether to simulate the action.

index<int>The index of the control to use when multiple controls match.

parent_element<Element> The parent control.

timeout<int> The timeout duration.

Code sample: rpa.app.edge.EdgeTab.process_prompt

# Notes:
# 1. Ensure the Alibaba Cloud RPA extension for Edge is installed and enabled.
# 2. This method supports prompt dialogs only.
# Usage example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.edge.create(url)
page.execute_js('prompt("Enter content:","")')
page.process_prompt('RPA_TEST')

Pos

pos(element, index=1, parent_element=None, timeout=10)

Description

Get the control's coordinates

Parameters

element<str> A control.

index<int> The index of the control to use when multiple controls match.

parent_element<str> The parent element.

timeout<int>Timeout period.

Sample Code: rpa.app.edge.EdgeTab.pos

# Notes:
# 1. Ensure the Alibaba Cloud RPA extension for Microsoft Edge is installed and enabled.
# 2. This method returns coordinates relative to the top-left corner of the screen. Therefore, the coordinate values will change if you move the browser window.
# Code example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.edge.create(url)
pos = page.pos('login button-edge')

Screenshot

screenshot(element, file, index=1, parent_element=None, timeout=10)

Description

Screenshot

Parameters

element<str> The control.

file<str> Path to the screenshot file.

index<int> The index of the control to use if more than one is found.

parent_element<str>The parent control object.

timeout<int>The timeout period.

Code example: rpa.app.edge.EdgeTab.screenshot

# Notes:
# 1. Ensure the Aliyun RPA Edge extension is installed and enabled.
# 2. Ensure you have recorded the page element by using control capture.
# Usage example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.edge.create(url)
save_path = r'D:\Alibaba Cloud bottom text screenshot.jpg'
page.screenshot('Bottom of page - pre-sales consultation-edge',save_path)

Mouse_move

mouse_move(element, index=1, parent_element=None, timeout=10)

Method

hover

Parameters

element<str> The control.

index<int> The index of the control, used when multiple controls are found.

parent_element<str>The parent element.

timeout<int> The timeout duration.

Code sample: rpa.app.edge.EdgeTab.mouse_move

# Notes:
# 1. Ensure the Alibaba Cloud RPA Edge extension is installed and enabled.
# 2. Before you start, ensure you have recorded the page element using capture control.
# Example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.edge.create(url)
page.mouse_move('Bottom of page - pre-sales consultation-edge')

Isvisible

isvisible(element, index=1, parent_element=None, timeout=10)

Description

Checks if the control is visible.

Parameters

element<str> The control.

index<int> The index of the desired control when multiple controls match.

parent_element<str>The parent control object.

timeout<int>The timeout duration.

Return value

Indicates whether the item is visible<bool>

Sample code: rpa.app.edge.EdgeTab.isvisible

# Notes:
# 1. Ensure the Aliyun RPA Edge extension is installed and enabled.
# 2. Before using this method, ensure the page element has been recorded with capture control.
# 3. This method checks the visibility property of a page element. If the element does not exist, it throws a wait for control timeout exception.
# This example opens a web page, uses JavaScript to make a page element invisible, and then calls this method:
url = 'www.baidu.com'
page = rpa.app.edge.create(url)
js = """
function set_display(){
    var div1 = document.getElementById("su");
    div1.style.display = "none";
};
set_display()
"""
page.execute_js(js)

flag = page.isvisible('baidu_search_button-edge')

Drag

drag(element, x=0, y=0, speed_mode='uniform', index=1, parent_element=None, timeout=10)

Description

Drags the element by a specified offset.

Parameter

element<str> The control

x<int> x-axis offset

y<int>Y-axis offset

speed_mode<str>The speed mode for the drag operation.

  • uniform: Drags at a constant speed.

  • fast-slow-pause: Simulates a human-like drag by accelerating, decelerating, and then pausing to align.

index<int> The index of the control to use in case of multiple matches.

parent_element<str> The parent element.

timeout<int>The timeout value.

Example: RPA.app.edge.EdgeTab.drag

# Notes:
# 1. To use this method, you must have the Alibaba Cloud RPA extension for Edge installed and enabled.
# 2. Before using this method, you must have recorded the page element using capture control.
# Usage example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.edge.create(url)
page.drag('login_button-edge',x=-500,y=100)

(Deprecated) clear_input

clear_input(element, index=1, parent_element=None, timeout=10)

Description

Clears the text from an input field.

Warning
  1. For client versions 4.10.3.1033 and later, use clear_input_simulated or clear_input_directed.

  2. This method is still functional. Existing automation processes that use this method are not affected.

Parameters

element<str> The name of the control.

index<int> The index of the control to use if multiple controls are found.

parent_element<str> The parent control object.

timeout<int> The timeout for finding the control, in seconds.

Code sample: rpa.app.edge.EdgeTab.clear_input

# Notes:
# 1. This method requires the Aliyun RPA extension for Edge to be installed and enabled.
# 2. Before use, record the page element using the capture control feature.
# Usage example:
url = 'www.aliyun.com'
page = rpa.app.edge.create(url)
page.clear_input('search-input')

clear_input_simulated

clear_input_simulated(element, index=1, parent_element=None, mode = 'native', timeout=10):

Description

Simulates clearing an input field.

Note

This feature is available in client version 4.10.3.1033 and later.

Parameters

element<str> The name of the element.

index<int> The index of the element to use when multiple matches are found.

parent_element<str> The name of the parent element.

mode<str> The input mode. Valid values are native, cdp, and driver.

  • native: Uses the operating system interface to clear the input.

  • cdp: Uses the browser extension to simulate clearing the input.

  • driver: Uses the driver to simulate keyboard actions to clear the input.

    Important

    For usage restrictions, see Driver input limitations.

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

Code sample

# Notes:
# 1. Make sure that the Aliyun RPA extension for Edge is installed and enabled.
# 2. Before use, ensure you have recorded the page element with the capture element feature.
# Sample code:
# 1. Enter some text.
# 2. Clear the input field.

url = 'www.aliyun.com'
page = rpa.app.edge.create(url)
page.input_text_simulated('search-input','Aliyun RPA')
page.clear_input_simulated('search-input')

clear_input_directed

clear_input_directed(element, index=1, parent_element=None, timeout=10)

Description

Clears an input field by modifying its HTML attribute.

Note

This feature requires client version 4.10.3.1033 or later.

Important
  1. This method is fast, but its success depends on the front-end implementation of the target web page and is not guaranteed.

  2. For better reliability, using clear_input_simulated is recommended.

Parameters

element<str> The name of the element.

index<int> The index of the element to use if multiple matches are found.

parent_element<str> An object that represents the parent element, which is used to scope the element search.

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

Code sample

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, ensure the page element has been recorded with the element capture feature.
#
# Usage example:
# 1. First, input some text.
# 2. Then, call this method to clear the input.

url = 'www.aliyun.com'
page = rpa.app.edge.create(url)
page.input_text_simulated('search-input','Alibaba Cloud RPA')
page.clear_input_directed('search-input')