EdgeElement

更新时间:
复制 MD 格式

scroll_into_view

scroll_into_view()

Description

Scrolls the element into the visible viewport.

Example- rpa.app.edge.EdgeTab.EdgeElement.scroll_into_view-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# Code example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.edge.create(url)
element = page.get_element_by_name('网页底部-售前咨询-edge')
element.scroll_into_view()

click

click(simulate=True, button='left', offset_x=0, offset_y=0,move_mode="with-track",speed_mode="uniform")

Description

Clicks the element.

Parameters

simulate<bool>Specifies whether to simulate a click. Defaults to True.

button<str>The mouse button to use.

Options:

  • left: Left mouse button.

  • right: Right mouse button.

offset_x<int>The horizontal offset in pixels from the center of the element. Defaults to 0.

offset_y<int>The vertical offset in pixels from the center of the element. Defaults to 0.

move_mode<str>The mouse movement mode for the click. This parameter applies only when simulate is True.

Options:

  • without-track: Instantly moves the mouse to the element and clicks.

  • with-track: Simulates human-like mouse movement to the element before clicking.

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

  • uniform: Moves the mouse at a constant speed.

Example- rpa.app.edge.EdgeTab.EdgeElement.click-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# Code example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.edge.create(url)
element = page.get_element_by_name('登录按钮-edge')

element.click()

double_click

double_click(simulate=True, offset_x=0, offset_y=0)

Description

Double-clicks the element.

Parameters

simulate<bool>Specifies whether to simulate the double-click. Defaults to True.

offset_x<int>The horizontal offset in pixels from the center of the element. Defaults to 0.

offset_y<int>The vertical offset in pixels from the center of the element. Defaults to 0.

Example- rpa.app.edge.EdgeTab.EdgeElement.double_click-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# Code example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.edge.create(url)
element = page.get_element_by_name('queryClientViews-edge')

element.double_click()

input_text (Deprecated)

input_text(value, simulate=True, replace=True, sent_raw=False, wait_mili_seconds=20)

Description

Enters text into the element.

Warning
  1. For client versions 4.10.3.1033 and later, use input_text_simulated or input_text_directed.

  2. This method is still functional and does not affect existing automation flows.

Parameters

value<str>The text to input.

simulate<bool>Specifies whether to simulate user input. Defaults to True.

replace<bool>Specifies whether to clear existing text before input. Defaults to True.

sent_raw<bool>Specifies whether to send raw keystrokes. This parameter applies only when simulate is False.

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

Example- rpa.app.edge.EdgeTab.EdgeElement.input_text-

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

element.input_text('Alibaba Cloud RPA')

input_text_simulated

input_text_simulated(value, mode = 'native', replace=True, keystroke_interval=20, timeout=10)

Description

Enters text by simulating user keystrokes.

Note

Available in client versions 4.10.3.1033 and later.

Parameters

value<str>The text to input.

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

  • native: Uses the operating system's API to input text.

  • cdp: Uses the browser extension to simulate typing.

  • driver: Uses the driver to simulate keyboard input.

    Important

    The driver mode supports only uppercase and lowercase English letters, numbers, and special characters on the keyboard. It does not support other characters, such as Chinese characters.

    Important

    The driver mode requires running the Alibaba Cloud RPA client with administrator privileges.

replace<bool>Specifies whether to clear existing text before input. Defaults to True.

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

timeout<int>The timeout in seconds for locating the element.

Example- rpa.app.edge.EdgeTab.EdgeElement.input_text_simulated-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# Code example:

url = 'www.aliyun.com'
page = rpa.app.edge.create(url)
element = page.get_element_by_name('search-input')

element.input_text_simulated('Alibaba Cloud RPA')

input_text_directed

input_text_directed(value, replace=True, timeout=10)

Description

Enters text by directly modifying the element's HTML attributes.

Note

Available in client versions 4.10.3.1033 and later.

Important
  1. This method is fast but may not work on all web pages, as its success depends on the page's front-end implementation.

  2. Use input_text_simulated as the primary option.

Parameters

value<str>The text to input.

replace<bool>Specifies whether to clear existing text before input. Defaults to True.

timeout<int>The timeout in seconds for locating the element.

Example- rpa.app.edge.EdgeTab.EdgeElement.input_text_directed-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# Code example:

url = 'www.aliyun.com'
page = rpa.app.edge.create(url)
element = page.get_element_by_name('search-input')

element.input_text_directed('Alibaba Cloud RPA')

input_hotkeys

input_hotkeys(value)

Description

Inputs a hotkey. For details, see input_hotkey usage and virtual key code list.

Parameters

value<str>The virtual key code.

Example- rpa.app.edge.EdgeTab.EdgeElement.input_hotkeys-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# Code example:
url = 'www.taobao.com'
page = rpa.app.edge.create(url)
element = page.get_element_by_name('淘宝输入框')
element.input_text('Alibaba Cloud')
element.input_hotkeys('VK_RETURN')

download

download(path, suffix=None, prepare_timeout=10, complete_timeout=120)

Description

Clicks the element to download a file and waits for the download to complete.

Parameters

path<str>The full file path to store the downloaded file.

suffix<str>The suffix format for the filename.

Options:

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

  • date: Appends the date (YYYYMMDD).

prepare_timeout<int>The timeout in seconds to wait for the download to begin.

complete_timeout<int>The timeout in seconds to wait for the download to complete.

Return value

Returns True if the download was successful, False otherwise.

Example- rpa.app.edge.EdgeTab.EdgeElement.download-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# Code example:
url = 'http://www.cninfo.com.cn/new/disclosure/detail?plate=hke&orgId=9900042435&stockCode=09988&announcementId=1209275224'
page = rpa.app.edge.create(url)
element = page.get_element_by_name('公告下载-edge')
download_path = r'D:\阿里巴巴-SW-公开资料.pdf'

element.download(download_path)

upload

upload(file)

Description

Clicks the element to upload a file and waits for the upload to complete.

Parameters

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

Example- rpa.app.edge.EdgeTab.EdgeElement.upload-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# Code example:
url = 'https://duguang.aliyun.com/experience?type=standard&subtype=idcard#intro'
page = rpa.app.edge.create(url)
upload_path = r'D:\2_测试文件归档\OCR身份证识别.jpg'
element = page.get_element_by_name('上传图片-edge')

element .upload(upload_path)

execute_js

execute_js(code)

Description

Executes JavaScript code in the context of the element.

Parameters

code<str>The JavaScript code to execute.

Return value

The execution result as a JSON string (<str>).

Example- rpa.app.edge.EdgeTab.EdgeElement.execute_js-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# Code example:
url = 'www.baidu.com'
page = rpa.app.edge.create(url)
js = """
var div1 = document.getElementById("su");
div1.style.display = "none";
"""
element = page.get_element_by_name('百度一下-edge')

element.execute_js(js)

text

text()

Description

Gets the text content of the element.

Return value

The text content of the element as a string (<str>).

Example- rpa.app.edge.EdgeTab.EdgeElement.text-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# Code example:
url = 'www.baidu.com'
page = rpa.app.edge.create(url)
element = page.get_element_by_name('百度一下-edge')

text = element.text()

html

html()

Description

Gets the outer HTML of the element.

Return value

The outer HTML of the element as a string (<str>).

Example- rpa.app.edge.EdgeTab.EdgeElement.html-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# Code example:
url = 'www.baidu.com'
page = rpa.app.edge.create(url)
element = page.get_element_by_name('百度一下-edge')

html= element.html()

value

value()

Description

Gets the value attribute of the element.

Return value

The element's value attribute as a string (<str>).

Example- rpa.app.edge.EdgeTab.EdgeElement.value-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# 3. This method retrieves the value of the `value` attribute from the element's HTML tag.
# Code example:
url = 'www.baidu.com'
page = rpa.app.edge.create(url)
element = page.get_element_by_name('百度一下-edge')

value= element.value()

option

option(text, type='match')

Description

Selects an option in a drop-down list by its text.

Parameters

text<str>The text of the option to select.

type<str>The matching strategy for the option text.

Options:

  • match: Partial match.

  • full: Exact match.

  • regex: Regular expression match.

Example- rpa.app.edge.EdgeTab.EdgeElement.option-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# 3. Make sure the drop-down list contains the specified text option.
# Code example:
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
page = rpa.app.edge.create(url)
element = page.get_element_by_name('下拉框-时刻表-edge')

element.option('00:00--06:00')

option_by_index

option_by_index(item_index)

Description

Selects an option in a drop-down list by its index.

Parameters

item_index<int>The index of the option to select. The index is 1-based.

Example- rpa.app.edge.EdgeTab.EdgeElement.option_by_index-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# 3. Check the number of options in the drop-down list. The index is 1-based and must not exceed the total number of options.
# Code example:
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
page = rpa.app.edge.create(url)
element = page.get_element_by_name('下拉框-时刻表-edge')

element.option_by_index(2)

get_options

get_options(mode='selected')

Description

Gets the selected option or all options from a drop-down list.

Parameters

mode<str>The type of options to return.

Options:

  • selected: Returns the currently selected option.

  • all: Returns all available options.

Return value

A list of options (<list>).

Example- rpa.app.edge.EdgeTab.EdgeElement.get_options-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# Code example:
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
page = rpa.app.edge.create(url)
element = page.get_element_by_name('下拉框-时刻表-edge')

options = element.get_options()

get_checked_state

get_checked_state()

Description

Gets the checked state of an element, such as a checkbox or radio button.

Return value

Returns True if the element is checked, False otherwise.

Example- rpa.app.edge.EdgeTab.EdgeElement.get_checked_state-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# Code example:
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
page = rpa.app.edge.create(url)
element = page.get_element_by_name('复选框-动车-edge')

check_state = element.get_checked_state()

set_checked_state

set_checked_state(value=True)

Description

Sets the checked state of an element.

Parameters

value<bool>True to check the element, or False to uncheck it.

Example- rpa.app.edge.EdgeTab.EdgeElement.set_checked_state-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# Code example:
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
page = rpa.app.edge.create(url)
element = page.get_element_by_name('复选框-动车-edge')

element.set_checked_state(False)

attr

attr(name)

Description

Gets the value of a specified attribute of the element.

Parameters

name<str>The name of the attribute.

Return value

The attribute value as a string (<str>).

Example- rpa.app.edge.EdgeTab.EdgeElement.attr-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# Code example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.edge.create(url)
element = page.get_element_by_name('登录按钮-edge')

attribute = element.attr('class')

pos

pos()

Description

Gets the on-screen position (x, y coordinates) of the element.

Example- rpa.app.edge.EdgeTab.EdgeElement.pos-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# Code example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.edge.create(url)
element = page.get_element_by_name('登录按钮-edge')

pos_dict = element.pos()

screenshot

screenshot(file)

Description

Takes a screenshot of the element.

Parameters

file<str>The path where the screenshot is saved.

Example- rpa.app.edge.EdgeTab.EdgeElement.screenshot-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# Code example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.edge.create(url)
element = page.get_element_by_name('登录按钮-edge')
save_path = r'D:\阿里云登录按钮.jpg'

element .screenshot(save_path)

mouse_move

mouse_move()

Description

Moves the cursor over the element.

Example- rpa.app.edge.EdgeTab.EdgeElement.mouse_move-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# Code example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.edge.create(url)
element = page.get_element_by_name('登录按钮-edge')

element .mouse_move()

isvisible

isvisible()

Description

Checks if the element is visible in the viewport.

Return value

Returns True if the element is visible, False otherwise.

Example- rpa.app.edge.EdgeTab.EdgeElement.isvisible-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# Code example: This example first uses JavaScript to hide the element, and then calls this method to check its visibility.
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.edge.create(url)
element = page.get_element_by_name('登录按钮-edge')
js = """
var div1 = document.getElementById("su");
div1.style.display = "none";
"""
element.execute_js(js)

flag = element.isvisible()

drag

drag(x=0, y=0,speed_mode='uniform')

Description

Drags the element by a specified offset.

Parameters

x<int>The horizontal drag offset in pixels.

y<int>The vertical drag offset in pixels.

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

  • uniform: Drags at a constant speed.

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

Example- rpa.app.edge.EdgeTab.EdgeElement.drag-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# Code example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.edge.create(url)
element = page.get_element_by_name('登录按钮-edge')

element.drag(x=-500,y=100)

clear (Deprecated)

clear()

Description

Clears the content of an input box.

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 and does not affect existing automation flows.

Example- rpa.app.edge.EdgeTab.EdgeElement.clear-

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

element.clear()

clear_input_simulated

clear_input_simulated(mode = 'native', timeout=10)

Description

Clears the content of an input box by simulating user actions.

Note

Available in client versions 4.10.3.1033 and later.

Parameters

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

  • native: Uses the operating system's API to clear the content.

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

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

    Important

    The driver mode requires running the Alibaba Cloud RPA client with administrator privileges.

timeout<int>The timeout in seconds for locating the element.

Example- rpa.app.edge.EdgeTab.EdgeElement.clear_input_simulated-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# Code example:
# 1. Input text into the input box.
# 2. Call this method to clear the input text.

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

clear_input_directed

clear_input_directed(timeout=10)

Description

Clears the content of an input box by directly modifying its HTML attributes.

Note

Available in client versions 4.10.3.1033 and later.

Important
  1. This method is fast but may not work on all web pages, as its success depends on the page's front-end implementation.

  2. Use clear_input_simulated as the primary option.

Parameters

timeout<int>The timeout in seconds for locating the element.

Example- rpa.app.edge.EdgeTab.EdgeElement.clear_input_directed-

# Notes:
# 1. This method requires the Alibaba Cloud RPA extension for Edge to be installed and enabled.
# 2. Before use, capture the page element by using the control capture feature.
# Code example:
# 1. Input text into the input box.
# 2. Call this method to clear the input text.

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