scroll_into_view
scroll_into_view()
Description
Scrolls the element into the visible area of the browser.
Example rpa.app.chrome.ChromeTab.ChromeElement.scroll_into_view
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# The following code provides an example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.chrome.create(url)
element = page.get_element_by_name('pre-sales-consulting-at-bottom-chrome')
element.scroll_into_view()click
click(simulate=True, button='left', offset_x=0, offset_y=0, move_mode="without-track", speed_mode="uniform")
Description
Click.
Parameters
simulate<bool> Specifies whether to simulate a click.
button<str> The mouse button to use.
Options:
left: The left mouse button.
right: The right mouse button.
offset_x<int> The horizontal offset.
offset_y<int> The vertical offset.
move_mode<str> The mouse movement mode for the click. This parameter is valid only when simulate is set to True.
Options:
without-track: The mouse moves to the control and clicks without a visible path.
with-track: The mouse moves to the control along a simulated path and then clicks.
speed_mode<str> The speed mode of the mouse movement. This parameter is valid only when simulate is set to True and move_mode is set to with-track.
uniform: Moves at a constant speed.
Example rpa.app.chrome.ChromeTab.ChromeElement.click
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# The following code provides an example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.chrome.create(url)
element = page.get_element_by_name('logon-button-chrome')
element.click()double_click
double_click(simulate=True, offset_x=0, offset_y=0)
Description
Double-clicks the element.
Parameters
simulate<bool> Indicates whether to simulate a click.
offset_x<int> The horizontal offset.
offset_y<int> The vertical offset.
Example rpa.app.chrome.ChromeTab.ChromeElement.double_click
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# The following code provides an example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.chrome.create(url)
element = page.get_element_by_name('queryClientViews-chrome')
element.double_click()input_text (deprecated)
input_text(value, simulate=True, replace=True, sent_raw=False, wait_mili_seconds=20)
Description
Enter text
For client versions 4.10.3.1033 and later, use input_text_simulated or input_text_directed.
This method is still functional. Automation flows that already use this method are not affected.
Parameters
value<str> The text to enter.
simulate<bool> Specifies whether to simulate the text input.
replace<bool> Specifies whether to clear existing content before entering new text.
sent_raw<bool> Specifies whether to send raw keystrokes. This parameter is valid only in non-simulated mode.
wait_mili_seconds<int> The interval between character inputs in milliseconds. This parameter is valid only in simulated mode. The default value is 20 and the maximum value is 100. A large value may cause a timeout.
Example rpa.app.chrome.ChromeTab.ChromeElement.input_text
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# The following code provides an example:
url = 'www.aliyun.com'
page = rpa.app.chrome.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 using a simulated method.
This feature is available in client versions 4.10.3.1033 and later.
Parameters
value<str> The text to enter.
mode<str> The input method. Valid values are native, cdp, and driver.
native: Uses the operating system interface to enter text.
cdp: Uses the browser extension to simulate typing.
driver: Uses the driver to simulate keyboard input.
ImportantFor more information about the limits, see Driver input limits.
replace<bool> Specifies whether to clear existing content before entering new text.
keystroke_interval<int> The interval between character inputs in milliseconds. This parameter is valid only in simulated mode. The default value is 20 and the maximum value is 100. A large value may cause a timeout.
timeout<int> The timeout period for finding the control, in seconds.
Example rpa.app.chrome.ChromeTab.ChromeElement.input_text_simulated
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# The following code provides an example:
url = 'www.aliyun.com'
page = rpa.app.chrome.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 modifying the HTML attribute.
This feature is available in client versions 4.10.3.1033 and later.
This method is fast but may not work on all web pages due to limitations of the frontend implementation.
Use input_text_simulated as the preferred option.
Parameters
value<str> The text to enter.
replace<bool> Specifies whether to clear existing content before entering new text.
timeout<int> The timeout period for finding the control, in seconds.
Example rpa.app.chrome.ChromeTab.ChromeElement.input_text_directed
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# The following code provides an example:
url = 'www.aliyun.com'
page = rpa.app.chrome.create(url)
element = page.get_element_by_name('search-input')
element.input_text_directed('Alibaba Cloud RPA')input_hotkeys
input_hotkeys(value)
Description
Enters a keyboard shortcut. For more information, see input_hotkey usage and virtual key code list.
Parameters
value<str> The virtual key code.
Example rpa.app.chrome.ChromeTab.ChromeElement.input_hotkeys
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# The following code provides an example:
url = 'www.taobao.com'
page = rpa.app.chrome.create(url)
element = page.get_element_by_name('Taobao-input-box')
element.input_text('Alibaba Cloud')
element.input_hotkeys('VK_RETURN')download
download(path, suffix=None, prepare_timeout=10, complete_timeout=120)
Description
Clicks a control to download a file and waits for the download to complete. The file is first downloaded to the browser's default download location and then automatically moved to the specified path.
Disable the "Ask where to save each file before downloading" option in your browser settings, as shown in the following figure.

If this option is disabled: Duplicate files are automatically overwritten.
If this option is enabled: A confirmation window appears if a file with the same name exists in the download location. This interrupts the automation flow.
Parameters
path<str> The full path where the downloaded file is saved.
suffix<str> The format of the suffix to add to the filename. Options:
datetime: Date and time (YYYYMMDDHHmm).
date: Date (YYYYMMDD).
prepare_timeout<int> The timeout period for the download to start.
complete_timeout<int> The timeout period for the download to complete.
Return value
Returns a boolean value that indicates whether the download was successful.<bool>
Example rpa.app.chrome.ChromeTab.ChromeElement.download
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# The following code provides an example:
url = 'https://www.cninfo.com.cn/new/disclosure/detail?plate=hke&orgId=9900042435&stockCode=09988&announcementId=1209275224'
page = rpa.app.chrome.create(url)
element = page.get_element_by_name('announcement-download-chrome')
download_path = r'D:\Alibaba-SW-Public-Info.pdf'
element.download(download_path)upload
upload(file)
Description
Clicks a control to start an upload and waits for the upload to complete.
Parameters
file<str> The full path of the file to upload.
Example rpa.app.chrome.ChromeTab.ChromeElement.upload
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# The following code provides an example:
url = 'https://duguang.aliyun.com/experience?type=standard&subtype=idcard#intro'
page = rpa.app.chrome.create(url)
upload_path = r'D:\2_Test_File_Archive\OCR_ID_Card_Recognition.jpg'
element = page.get_element_by_name('upload-image-chrome')
element .upload(upload_path)execute_js
execute_js(code)
Description
Executes JavaScript code.
Parameters
code<str> The JavaScript code to execute.
Return value
Returns the execution result as a JSON string.<str>
Example rpa.app.chrome.ChromeTab.ChromeElement.execute_js
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# The following code provides an example:
url = 'www.baidu.com'
page = rpa.app.chrome.create(url)
js = """
var div1 = document.getElementById("su");
div1.style.display = "none";
"""
element = page.get_element_by_name('Baidu-Search-chrome')
element.execute_js(js)text
text()
Description
Retrieves the text content of the element.
Return value
Returns the text content of the element.<str>
Example rpa.app.chrome.ChromeTab.ChromeElement.text
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# The following code provides an example:
url = 'www.baidu.com'
page = rpa.app.chrome.create(url)
element = page.get_element_by_name('Baidu-Search-chrome')
text = element.text()html
html()
Description
Retrieves the HTML source code of the element.
Return value
Returns the text content of the <str> element.
Example rpa.app.chrome.ChromeTab.ChromeElement.html
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# The following code provides an example:
url = 'www.baidu.com'
page = rpa.app.chrome.create(url)
element = page.get_element_by_name('Baidu-Search-chrome')
html= element.html()value
value()
Description
Retrieves the value of the element.
Return value
Returns the value of the element.<str>
Example rpa.app.chrome.ChromeTab.ChromeElement.value
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# 3. This method gets the value of the value attribute in the element's HTML tag.
# The following code provides an example:
url = 'www.baidu.com'
page = rpa.app.chrome.create(url)
element = page.get_element_by_name('Baidu-Search-chrome')
value= element.value()option
option(text, type='match')
Description
Selects an option from a drop-down list based on text.
Parameters
text<str> The text of the option to select.
type<str> The matching type.
Options:
match: Fuzzy match.
full: Exact match.
regex: Regular expression matching.
This method only supports HTML select elements, as shown in the following figure. To operate on drop-down lists implemented by other methods, see Example: Dynamically select from a drop-down list.

Example rpa.app.chrome.ChromeTab.ChromeElement.option
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# 3. Make sure the specified text option exists in the drop-down list.
# The following code provides an example:
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
page = rpa.app.chrome.create(url)
element = page.get_element_by_name('dropdown-timetable-chrome')
element.option('00:00--06:00')option_by_index
option_by_index(item_index)
Description
Selects an option from a drop-down list by its index.
Parameters
item_index<int> The index of the option. The index starts from 1.
This method only supports HTML select elements. For more information, see option.
Example rpa.app.chrome.ChromeTab.ChromeElement.option_by_index
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# 3. Make sure the index is within the valid range of options. The index starts from 1.
# The following code provides an example:
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
page = rpa.app.chrome.create(url)
element = page.get_element_by_name('dropdown-timetable-chrome')
element.option_by_index(2)get_options
get_options(mode='selected')
Description
Returns the selected option or all options from a drop-down list.
Parameters
mode<str> The type of options to return.
Options:
selected: The selected option.
all: All options.
Return value
Returns a list of options.<list>
This method only supports HTML select elements. For more information, see option.
Example rpa.app.chrome.ChromeTab.ChromeElement.get_options
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# The following code provides an example:
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
page = rpa.app.chrome.create(url)
element = page.get_element_by_name('dropdown-timetable-chrome')
options = element.get_options()get_checked_state
get_checked_state()
Description
Retrieves the checked state of a check box or radio button.
Return value
Returns the checked state.<bool>
Example rpa.app.chrome.ChromeTab.ChromeElement.get_checked_state
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# The following code provides an example:
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
page = rpa.app.chrome.create(url)
element = page.get_element_by_name('checkbox-bullet-train-chrome')
check_state = element.get_checked_state()set_checked_state
set_checked_state(value=True)
Description
Sets the checked state of a check box or radio button.
Parameters
value<bool> Set to True to check the box, or False to uncheck it.
Example rpa.app.chrome.ChromeTab.ChromeElement.set_checked_state
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# The following code provides an example:
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
page = rpa.app.chrome.create(url)
element = page.get_element_by_name('checkbox-bullet-train-chrome')
element.set_checked_state(False)attr
attr(name)
Description
Retrieves an attribute of the element.
Parameters
name<str> The attribute name.
Return value
Returns the attribute value.<str>
Example rpa.app.chrome.ChromeTab.ChromeElement.attr
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# The following code provides an example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.chrome.create(url)
element = page.get_element_by_name('logon-button-chrome')
attribute = element.attr('class')pos
pos()
Description
Retrieves the coordinates of the control.
The control must be visible on the screen. You may need to use the following methods:
The browser tab must be active. Use activate to activate it.
Use scroll_into_view or scroll to scroll the page.
Example rpa.app.chrome.ChromeTab.ChromeElement.pos
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# The following code provides an example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.chrome.create(url)
element = page.get_element_by_name('logon-button-chrome')
pos_dict = element.pos()screenshot
screenshot(file)
Description
Control Screenshot
Parameters
file<str> The path to save the screenshot.
The control must be visible on the screen. You may need to use the following methods:
The browser tab must be active. Use activate to activate it.
Use scroll_into_view or scroll to scroll the page.
Example rpa.app.chrome.ChromeTab.ChromeElement.screenshot
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# The following code provides an example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.chrome.create(url)
element = page.get_element_by_name('logon-button-chrome')
save_path = r'D:\AlibabaCloud-logon-button.jpg'
element .screenshot(save_path)mouse_move
mouse_move()
Description
Moves the mouse cursor over the element.
Example rpa.app.chrome.ChromeTab.ChromeElement.mouse_move
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# The following code provides an example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.chrome.create(url)
element = page.get_element_by_name('logon-button-chrome')
element .mouse_move()isvisible
isvisible()
Description
Retrieves the visibility state of the control.
Return value
Returns whether the control is visible <bool>
Example rpa.app.chrome.ChromeTab.ChromeElement.isvisible
# Notes:
# 1. You must confirm that the Alibaba Cloud RPA Chrome extension is installed and enabled.
# 2. Before use, confirm that you have used the capture control feature to record page elements.
# Code example below. In this example, JavaScript code is first used to set the element to invisible, and then this method is called:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.chrome.create(url)
element = page.get_element_by_name('Logon button-chrome')
js = """
var div1 = document.getElementById("su");
div1.style.display = "none";
"""
element.excute_js(js)
flag = element.isvisible()drag
drag(x=0, y=0, speed_mode='uniform')
Description
Drags the element to a specified position.
Parameters
x<int> The offset on the x-axis.
y<int> The offset on the y-axis.
speed_mode<str> The speed mode for dragging.
uniform: Drags at a constant speed.
fast-slow-pause: Accelerates, then decelerates, and finally pauses to align. This simulates human dragging behavior.
Example rpa.app.chrome.ChromeTab.ChromeElement.drag
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# The following code provides an example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.chrome.create(url)
element = page.get_element_by_name('logon-button-chrome')
element.drag(x=-500,y=100)clear (deprecated)
clear()
Description
Clears the input box.
For client versions 4.10.3.1033 and later, use clear_input_simulated or clear_input_directed.
This method is still functional. Automation flows that already use this method are not affected.
Example rpa.app.chrome.ChromeTab.ChromeElement.clear
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# The following code provides an example:
url = 'www.aliyun.com'
page = rpa.app.chrome.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 using a simulated method.
This feature is available in client versions 4.10.3.1033 and later.
Parameters
mode<str> The input method. Valid values are native, cdp, and driver.
native: Uses the operating system interface 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.
ImportantFor more information about the limits, see Driver input limits.
timeout<int> The timeout period for finding the control, in seconds.
Example rpa.app.chrome.ChromeTab.ChromeElement.clear_input_simulated
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# The following code provides an example:
# 1. First, enter text.
# 2. Then, call this method to clear the entered text.
url = 'www.aliyun.com'
page = rpa.app.chrome.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 modifying the HTML attribute.
This feature is available in client versions 4.10.3.1033 and later.
This method is fast but may not work on all web pages due to limitations of the frontend implementation.
Use clear_input_simulated as the preferred option.
Parameters
timeout<int> The timeout period for finding the control, in seconds.
Example rpa.app.chrome.ChromeTab.ChromeElement.clear_input_directed
# Notes:
# 1. Before using this method, make sure the Alibaba Cloud RPA extension for Chrome is installed and enabled.
# 2. Before using this method, make sure you have recorded the page element using the control capture feature.
# The following code provides an example:
# 1. First, enter text.
# 2. Then, call this method to clear the entered text.
url = 'www.aliyun.com'
page = rpa.app.chrome.create(url)
element = page.get_element_by_name('search-input')
element.input_text_simulated('Alibaba Cloud RPA')
element.clear_input_directed()