close
close()
Description
Closes the browser tab.
Example: rpa.app.chrome.ChromeTab.close
# Note: This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# This method must be operated on a ChromeTab instance object.
# The following is a code example:
page = rpa.app.chrome.create('www.aliyun.com')
page.close()navigate
navigate(url, wait=True, timeout=100)
Description
Navigates to a specified URL.
Parameters
url<str>: The URL to open.
wait<bool>: Specifies whether to wait for the page to load.
timeout<int>: The timeout period, in seconds. The default value is 100.
Example: rpa.app.chrome.ChromeTab.navigate
# Note: This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# This method must be operated on a ChromeTab instance object.
# The following is a code example:
url = 'www.aliyun.com'
page = rpa.app.chrome.create(url)
page.navigate('help.aliyun.com/document_detail/175379.html')back
back(wait=True, timeout=100)
Description
Goes back one page in the browser history.
Parameters
wait<bool>: Specifies whether to wait for the page to load.
timeout<int>: The timeout period, in seconds. The default value is 100.
Example: rpa.app.chrome.ChromeTab.back
# Note: This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# This method must be operated on a ChromeTab instance object.
# The following is a code example:
url = 'www.baidu.com'
page = rpa.app.chrome.create(url)
page.input_text('baidu_input_box','Alibaba Cloud')
page.click('baidu_search_button', simulate=True)
page.back()forward
forward(wait=True, timeout=100)
Description
Goes forward one page in the browser history.
Parameters
wait<bool>: Specifies whether to wait for the page to load.
timeout<int>: The timeout period, in seconds. The default value is 100.
Example: rpa.app.chrome.ChromeTab.forward
# Note: This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# This method must be operated on a ChromeTab instance object.
# The following is a code example:
url = 'www.aliyun.com'
page = rpa.app.chrome.create(url)
page.navigate('help.aliyun.com/document_detail/175379.html')
page.back()
page.forward()activate
activate()
Description
Activates the page.
Example: rpa.app.chrome.ChromeTab.activate
# Note: This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# This method must be operated on a ChromeTab instance object.
# The following is a code example:
url = 'www.aliyun.com'
page = rpa.app.chrome.create(url)
page.activate()url
url()
Description
Retrieves the URL of the current page.
Return value
Returns the URL as a <str>.
Example: rpa.app.chrome.ChromeTab.url
# Note: This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# This method must be operated on a ChromeTab instance object.
# The following is a code example:
page = rpa.app.chrome.create('www.aliyun.com')
url = page.url()title
title()
Description
Retrieves the title of the current page.
Return value
Returns the title as a <str>.
Example: rpa.app.chrome.ChromeTab.title
# Note: This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# This method must be operated on a ChromeTab instance object.
# The following is a code example:
page = rpa.app.chrome.create('www.aliyun.com')
title= page.title()reload
reload(bypass_cache=False, wait=True, timeout=100)
Description
Reloads the current page.
Parameters
bypass_cache<bool>: Specifies whether to bypass the cache.
wait<bool>: Specifies whether to wait for the page to load.
timeout<int>: The timeout period, in seconds. The default value is 100.
Example: rpa.app.chrome.ChromeTab.reload
# Note: This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# This method must be operated on a ChromeTab instance object.
# The following is a code example:
page = rpa.app.chrome.create('www.aliyun.com')
page.reload()get_cookie
get_cookie()
Description
Retrieves all cookies for the current website.
Return value
Returns a <list> of all cookies for the current website.
Example: rpa.app.chrome.ChromeTab.get_cookie
# Note: This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# This method must be operated on a ChromeTab instance object.
# The following is a code example:
page = rpa.app.chrome.create('www.aliyun.com')
cookie = page.get_cookie()network_capture_start
network_capture_start(url='', use_regular=False, capture_types=[])
Description
Starts listening for web requests.
Parameters
url<str>: The URL to listen for. If this parameter is left empty, the listener monitors all URLs.
use_regular<bool>: Specifies whether to use a regular expression for URL matching.
capture_types<list>: The request types to listen for. Supported types include XHR/Fetch, XHR, Fetch, JS, CSS, Image, Font, Document, WebSocket, and Other.
Return value
Returns a <string> that represents the index key for the web request listener. You can use this key to retrieve the listening results or stop the listener.
Example: rpa.app.chrome.ChromeTab.network_capture_start
# Note: This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# This method must be operated on a ChromeTab instance object.
# The following is a code example:
# Open the Alibaba Cloud page in Google Chrome.
page = rpa.app.chrome.create('www.aliyun.com')
# Start listening for web requests.
capture_key = page.network_capture_start(url='', use_regular=False, capture_types=[])
# Refresh the page.
page.reload()
# Get the web request listening results.
web_respond_body = rpa.app.chrome.get_network_capture_result(capture_key)
# Stop listening for web requests.
rpa.app.chrome.network_capture_stop(capture_key)
# Record the information in the log.
rpa.console.logger.info(web_respond_body)wait_load_completed
wait_load_completed(timeout=100)
Description
Waits for the page to finish loading.
Parameters
timeout<int>: The timeout period, in seconds. The default value is 100.
Example: rpa.app.chrome.ChromeTab.wait_load_completed
# Note: This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# This method must be operated on a ChromeTab instance object.
# The following is a code example:
page = rpa.app.chrome.create('www.aliyun.com')
page.wait_load_completed()copy
copy()
Description
Performs a copy operation on the current page.
Return value
Returns a <bool> that indicates whether the operation was successful.
Example: rpa.app.chrome.ChromeTab.copy
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. This method only executes the copy instruction. Select the content to copy using another method before executing this one.
# 3. This method writes the content to the system clipboard.
# The following is a code example. In this example, double-clicking the cell content selects the corresponding text, and then the copy operation is performed.
page = rpa.app.chrome.create('https://help.aliyun.com/document_detail/175379.html')
page.double_click('queryClientViews-chrome')
page.copy()paste
paste()
Description
Performs a paste operation on the current page.
Return value
Returns a <bool> that indicates whether the operation was successful.
Example: rpa.app.chrome.ChromeTab.paste
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. This method only executes the paste instruction. Select the area to paste into using another method before executing this one.
# 3. This method pastes the latest content from the clipboard to the corresponding area.
# The following is a code example. In this example, after copying the cell content, the search box is clicked, and then the paste action is performed.
page = rpa.app.chrome.create('https://help.aliyun.com/document_detail/175379.html')
page.double_click('queryClientViews-chrome')
page.copy()
page.click('document_search_box-chrome')
page.paste()cut
cut()
Description
Performs a cut operation on the current page.
Return value
Returns a <bool> that indicates whether the operation was successful.
Example: rpa.app.chrome.ChromeTab.cut
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. This method only executes the cut instruction. Select the content that can be cut using another method before executing this one. This action will be invalid if the content itself cannot be cut.
# 3. This method writes the content to the system clipboard.
# The following is a code example. In this example, you must first manually open the Baidu homepage and enter any content in the input box.
# The program will double-click the input box to get the text within it, and then perform the cut action.
page = rpa.app.chrome.catch('www.baidu.com',mode='url')
page.double_click('baidu_input_box-chrome')
page.cut()execute_js
execute_js(code, element=None, index=1, timeout=10)
Description
Executes JavaScript code.
Parameters
code<str>: The JavaScript code.
element<str>: The control. For cross-domain operations, the JavaScript code is executed within the domain of this control.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
timeout<int>: The timeout period, in seconds.
Return value
Returns a JSON <str> that represents the execution result.
Example: rpa.app.chrome.ChromeTab.execute_js
# Note: This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# This method must be operated on a ChromeTab instance object.
# The following is a code 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.chrome.create(url)
value = page.execute_js(js_code)
print(value)table
table(value, type='index', return_type='text', parent_element=None)
Description
Retrieves a table.
Parameters
type<str>: The match type.
Options:
index: Matches by index.
text: Matches by text.
html: Matches by HTML content.
return_type<str>: The return type.
Options:
Text: Text type
html: HTML format
Return value
Returns a <list> that contains a 2D array or the HTML content of the matched table.
Example: rpa.app.chrome.ChromeTab.table
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. This method gets a standard table (HTML tag is table) on the page based on its index (starting from 1) or a regular expression.
# The following is a code example. After running, it will get the first table on the webpage (the content of the first table tag in order from top to bottom in the HTML).
page = rpa.app.chrome.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
Scrolls the page.
Parameters
height<int>: The scroll height. If this parameter is not set, the page scrolls to the bottom.
element<str>: The control.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<Element>: The parent control object.
timeout<int>: The timeout period, in seconds.
direction<str>: The scroll direction.
Options:
left: Scrolls to the left.
top: Scrolls down.
Example: rpa.app.chrome.ChromeTab.scroll
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. If no parameters are passed or the parameters are set to 0, this method will scroll the page slider to the bottom.
# The following is a code example:
page = rpa.app.chrome.create('https://help.aliyun.com/document_detail/175379.html')
page.scroll()
# To scroll the list information bar on the page, you need to pass parameters such as height and element. For example:
page.scroll(height=200, element='list_scroll_bar', index=1, parent_element=None, timeout=10, direction='top')
The control to record is the scrollable list itself. 
get_element_by_name
get_element_by_name(element, index=1, parent_element=None, timeout=10)
Description
Retrieves an element object.
Parameters
element<str>: The control.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<Element>: The parent control object.
timeout<int>: The timeout period, in seconds.
Return value
Returns the <Element> object.
Example: rpa.app.chrome.ChromeTab.get_element_by_name
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. Note: Before use, you need to capture the elements on the page using the control capturing feature.
# The following is a code example:
url = 'https://www.baidu.com/'
page = rpa.app.chrome.create(url)
element = page.get_element_by_name('baidu_search_button-chrome')
text = element.text()get_element_by_css
get_element_by_css(css, index=1, parent_element=None, timeout=10)
Description
Retrieves a control using a CSS expression.
Parameters
css<str>: The CSS expression.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<str>: The parent control object.
timeout<int>: The timeout period, in seconds.
Return value
Returns the <Element> object.
Example: rpa.app.chrome.ChromeTab.get_element_by_css
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. This method uses a CSS selector to locate the element to be operated on. Use a standard CSS selector expression.
# The following is a code example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.chrome.create(url)
css_selector = "span.lake-fontsize-11" # Represents a span tag with a class value of lake-fontsize-11
element = page.get_element_by_css(css_selector)
text = element.text()count
count(element, parent_element=None)
Description
Retrieves the number of matching controls.
Parameters
element<str>: The control.
parent_element<str>: The parent control object.
Example: rpa.app.chrome.ChromeTab.count
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. After capturing similar control elements using the similar control capturing feature, this method is often used to count the number of controls.
# The following is a code example:
url = 'www.aliyun.com'
page = rpa.app.chrome.create(url)
element_count = page.count('logon_button-chrome')wait_loaded
wait_loaded(element, index=1, parent_element=None, timeout=10, ignore_error=True)
Description
Waits for a control to load.
Parameters
element<str>: The control.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<str>: The parent control object.
timeout<int>: The timeout period, in seconds.
ignore_error<bool>: Specifies whether to ignore errors.
Example: rpa.app.chrome.ChromeTab.wait_loaded
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. Before use, confirm that the page elements have been recorded using the control capturing feature.
# The following is a code example:
page = rpa.app.chrome.create('www.taobao.com')
flag = page.wait_loaded('taobao_logo')wait_disappear
wait_disappear(element, index=1, parent_element=None, timeout=10)
Description
Waits for a control to disappear.
Parameters
element <str> - control
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<str>: The parent control object.
timeout<int>: The timeout period, in seconds.
Example: rpa.app.chrome.ChromeTab.wait_disappear
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. Before use, confirm that the page elements have been recorded using the control capturing feature.
# The following is a code example:
page = rpa.app.chrome.create('www.taobao.com')
page.wait_disappear('taobao_logo')handle_javascript_dialog
handle_javascript_dialog(value='ok', text=None)
Description
Handles a JavaScript dialog box.
Parameters
value<str>: The action to take on the dialog box.
Options:
ok: Clicks the OK button.
cancel: Clicks the Cancel button.
text<str>: The text to enter into the dialog box.
Example: rpa.app.chrome.ChromeTab.handle_javascript_dialog
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# The following is a code example:
page = rpa.app.chrome.catch('W3School TIY Editor', mode='title', pattern='contain')
page.click('Click_me_to_pop_up_a_window')
page.handle_javascript_dialog()Steps to create a page pop-up scenario:
First, open the W3School page.
Enter the HTML script in the script box on the left.
Click Run Code. A button that triggers a pop-up is generated on the right.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script>
function myFunction()
{
alert("Here I am to bother you~!");
}
</script>
</head>
<body>
<input type="button" onclick="myFunction()" value="Click me to pop up a window">
</body>
</html>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
Clicks a control.
Parameters
element<str>: The control.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<str>: The parent control object.
simulate<bool>: Specifies whether to simulate a click.
button<str>: The mouse button.
Options:
left: Left
Right-click
offset_x<int>: The horizontal offset.
offset_y<int>: The vertical offset.
move_mode<str>: The mouse movement mode when clicking. This parameter is valid only when simulate=True.
Options:
without-track: The mouse pointer moves to the control and clicks it without showing a movement track.
with-track: The mouse pointer moves to the control with a simulated movement track and clicks it.
speed_mode<str>: The mouse movement speed mode. This parameter is valid only when simulate=True and move_mode=with-track.
uniform: Moves at a uniform speed.
timeout<int>: The timeout period, in seconds.
Example: rpa.app.chrome.ChromeTab.click
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. Before use, confirm that the page elements have been recorded using the control capturing feature.
# 3. If simulate=True (simulated click), the corresponding page element must be in the visible area for the simulated mouse click.
# 4. If simulate=False (non-simulated click), the corresponding click instruction will be sent directly to the element.
# The following is a code example:
url = 'www.aliyun.com'
page = rpa.app.chrome.create(url)
page.click('logon_button-chrome')(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
Inputs text.
For client versions 4.10.3.1033 and later, we recommend using input_text_simulated or input_text_directed.
This method is still functional. Automation flows that use this method are not affected.
Parameters
element<str>: The name of the control.
value<str>: The content to input.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<str>: The parent control object.
simulate<bool>: Specifies whether to simulate the input.
replace<bool>: Specifies whether to clear existing content.
sent_raw<bool>: Specifies whether to send raw keystrokes. This parameter is valid only when simulate is set to False.
wait_mili_seconds<int>: The interval between characters, in milliseconds. This parameter is valid only for simulated input. The default value is 20 and the maximum value is 100. A value that is too large may cause a timeout.
timeout<int>: The timeout period for finding the control, in seconds.
Example: rpa.app.chrome.ChromeTab.input_text
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. Before use, confirm that the page elements have been recorded using the control capturing feature.
# The following is a code example:
url = 'www.aliyun.com'
page = rpa.app.chrome.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
Inputs text using simulation.
This feature is available in client versions 4.10.3.1033 and later.
Parameters
element<str>: The name of the control.
value<str>: The content to input.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
mode<str>: The input method. Valid values are native, cdp, and driver.
native: Uses the operating system interface to perform the input.
cdp: Uses a browser plug-in to simulate typing.
driver: Uses a driver to simulate keyboard input.
ImportantFor more information about the limitations, see Driver input limits.
parent_element<str>: The parent control object.
replace<bool>: Specifies whether to clear existing content.
keystroke_interval<int>: The interval between characters, in milliseconds. This parameter is valid only for simulated input. The default value is 20 and the maximum value is 100. A value that is too large may cause a timeout.
timeout<int>: The timeout period for finding the control, in seconds.
Example: rpa.app.chrome.ChromeTab.input_text_simulated
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. Before use, confirm that the page elements have been recorded using the control capturing feature.
# The following is a code example:
url = 'www.aliyun.com'
page = rpa.app.chrome.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 HTML attributes.
This feature is available in client versions 4.10.3.1033 and later.
This method is fast but may not work on all webpages due to their frontend implementation.
We recommend that you use input_text_simulated.
Parameters
element<str>: The name of the control.
value<str>: The content to input.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<str>: The parent control object.
replace<bool>: Specifies whether to clear existing content.
timeout<int>: The timeout period for finding the control, in seconds.
Example: rpa.app.chrome.ChromeTab.input_text_directed
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. Before use, confirm that the page elements have been recorded using the control capturing feature.
# The following is a code example:
url = 'www.aliyun.com'
page = rpa.app.chrome.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
Inputs a keyboard shortcut. For more information, see Usage of input_hotkey and list of virtual key codes.
Parameters
element<str>: The control.
value<str>: The virtual key code.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<str>: The parent control object.
timeout<int>: The timeout period, in seconds.
download_by_element
download_by_element(path, element, index=1, parent_element=None, wait=True, suffix=None, complete_timeout=120)
Description
Clicks a specified 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 moved to the specified path.
We recommend that you disable the "Ask where to save each file before downloading" option in your browser, as shown in the following figure.

If this option is disabled: If a file with the same name exists, it is automatically overwritten.
If this option is enabled: If a file with the same name exists in the browser's download location, a confirmation window appears, which may interrupt the automation flow.
Parameters
path<str>: The path to save the downloaded file.
element<str>: The control.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<Element>: The parent control object.
complete_timeout<int>: The timeout period for the download to complete, in seconds.
wait<bool>: Specifies whether to wait for the download to complete.
suffix<str>: The format of the suffix to automatically add to the filename. The supported values are as follows:
datetime: The date (year, month, and day) and the time (hour and minute).
date: Appends the date (YYYYMMDD).
Example: rpa.app.chrome.ChromeTab.download_by_element
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. Before use, capture the download button on the page using the control capturing feature and verify its availability.
# The following is a code example:
url = 'https://www.cninfo.com.cn/new/disclosure/detail?plate=hke&orgId=9900042435&stockCode=09988&announcementId=1209275224'
page = rpa.app.chrome.create(url)
download_path = r'D:\Alibaba-SW-Public_Info.pdf'
page.download_by_element(download_path,'announcement_download-chrome')download_by_url
download_by_url(url, path, wait=True, complete_timeout=120)
Description
Downloads a file from a specified URL and waits for the download to complete. The file is first downloaded to the browser's default download location and then moved to the specified path.
We recommend that you disable the "Ask where to save each file before downloading" option in your browser, as shown in the following figure.

If this option is disabled: If a file with the same name exists, it is automatically overwritten.
If this option is enabled: If a file with the same name exists in the browser's download location, a confirmation window appears, which may interrupt the automation flow.
Parameters
url<str>: The URL of the file to download.
path<str>: The path to save the downloaded file.
complete_timeout<int>: The timeout period for the download to complete, in seconds.
wait<bool>: Specifies whether to wait for the download to complete.
Example: rpa.app.chrome.ChromeTab.download_by_url
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# The following is a code example. After running, it will download the corresponding file to the specified path.
url = 'https://www.cninfo.com.cn'
page = rpa.app.chrome.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)
Description
Uploads a file.
Parameters
element <str>: The control.
file<str>: The path of the file to upload.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<str>: The parent control object.
timeout<int>: The timeout period, in seconds.
Example: rpa.app.chrome.ChromeTab.upload
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. Before use, capture the upload button on the page using the control capturing feature and verify its availability.
# The following is a code 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'
page.upload('upload_image-chrome',upload_path)text
text(element=None, index=1, parent_element=None, timeout=10)
Description
Retrieves text.
Parameters
element<str>: The control.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<str>: The parent control object.
timeout<int>: The timeout period, in seconds.
Return value
Returns the text as a <str>. If no control is specified, this method returns all text from the browser.
Example: rpa.app.chrome.ChromeTab.text
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. Before use, confirm that the page elements have been recorded using the control capturing feature.
# The following is a code example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.chrome.create(url)
text = page.text(element='webpage_footer-presales_consulting-chrome')html
html(element=None, index=1, parent_element=None, timeout=10)
Description
Retrieves HTML content.
Parameters
element<str>: The control.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<str>: The parent control object.
timeout<int>: The timeout period, in seconds.
Return value
Returns the HTML content as a <str>. If no control is specified, this method returns all HTML content from the browser.
Example: rpa.app.chrome.ChromeTab.html
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. Before use, confirm that the page elements have been recorded using the control capturing feature.
# The following is a code example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.chrome.create(url)
html = page.html('webpage_footer-presales_consulting-chrome')value
value(element, index=1, parent_element=None, timeout=10)
Description
Retrieves the value of a control.
Parameters
element<str>: The control.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<str>: The parent control object.
timeout<int>: The timeout period, in seconds.
Example: rpa.app.chrome.ChromeTab.value
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. Before use, confirm that the page elements have been recorded using the control capturing feature.
# The following is a code example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.chrome.create(url)
value = page.value('webpage_footer-presales_consulting-chrome')option
option(element, text, index=1, parent_element=None, type='match', timeout=10)
Description
Selects an option from a drop-down list.
Parameters
element<str>: The control.
text<str>: The option to select.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
type<str>: The match type.
Options:
match: Performs a fuzzy match.
full: Performs an exact match.
regex: Performs a regular expression match.
parent_element<str>: The parent control object.
timeout<int>: The timeout period, in seconds.
This method supports only HTML select elements, as shown in the following figure. To operate on drop-down lists that are implemented in other ways, see Example: Dynamic selection in a drop-down list.

Example: rpa.app.chrome.ChromeTab.option
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. Before use, capture the standard drop-down list element (HTML tag is select) on the page using the control capturing feature.
# 3. Confirm that the corresponding text option exists in the drop-down list.
# The following is a code example:
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
page = rpa.app.chrome.create(url)
page.option('dropdown_list-chrome','00:00--06:00')get_checked_state
get_checked_state(element, index=1, parent_element=None, timeout=10)
Description
Retrieves the checked state of a control, such as a checkbox or a radio button.
Parameters
element<str>: The control.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<str>: The parent control object.
timeout<int>: The timeout period, in seconds.
Return value
Returns a <bool> that indicates the checked state.
Example: rpa.app.chrome.ChromeTab.get_checked_state
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. Before use, confirm that the page elements have been recorded using the control capturing feature.
# The following is a code example:
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
page = rpa.app.chrome.create(url)
check_state = page.get_checked_state('checkbox-bullet_train-chrome')set_checked_state
set_checked_state(element, value=True, index=1, parent_element=None, timeout=10)
Description
Sets the checked state of a control, such as a checkbox or a radio button.
Parameters
element<str>: The control.
value<bool>: The checked state. Set this parameter to True to select the control or False to clear the control.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<str>: The parent control object.
timeout<int>: The timeout period, in seconds.
Example: rpa.app.chrome.ChromeTab.set_checked_state
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. Before use, confirm that the page elements have been recorded using the control capturing feature.
# The following is a code example:
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
page = rpa.app.chrome.create(url)
page.set_checked_state('checkbox-bullet_train-chrome', value=True)attr
attr(element, attrname, index=1, parent_element=None, timeout=10)
Description
You can retrieve an attribute.
Parameters
element <str>: The control.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<str>: The parent control object.
timeout<int>: The timeout period, in seconds.
Return value
Returns the attribute value as a <str>.
Example: rpa.app.chrome.ChromeTab.attr
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. Before use, confirm that the page elements have been recorded using the control capturing feature.
# The following is a code example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.chrome.create(url)
attribute = page.attr('logon_button-chrome','class')process_alert
process_alert(option='ok', element=None, simulate=True, index=1, parent_element=None, timeout=10)
Description
Clicks a button in a pop-up box.
Parameters
value <str> Pop-up handling
Options:
ok: Clicks the OK button.
cancel: Clicks the Cancel button.
element<str>: The control. If this parameter is not specified, the method clicks a button in a pop-up box within the browser.
simulate<bool>: Specifies whether to simulate the action.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<Element>: The parent control object.
timeout<int>: The timeout period, in seconds.
Example: rpa.app.chrome.ChromeTab.process_alert
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. This method can only handle confirm or alert pop-ups.
# The following is a code example:
page = rpa.app.chrome.catch('W3School TIY Editor', mode='title', pattern='contain')
page.click('Click_me_to_pop_up_a_window')
page.process_alert()Steps to create a page pop-up scenario:
First, open the W3School page.
Enter the HTML script in the script box on the left.
Click Run Code. A button that triggers a pop-up is generated on the right.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script>
function myFunction()
{
alert("Here I am to bother you~!");
}
</script>
</head>
<body>
<input type="button" onclick="myFunction()" value="Click me to pop up a window">
</body>
</html>process_prompt
process_prompt(text, option='ok', element=None, simulate=True, index=1, parent_element=None, timeout=10)
Description
Enters text into a prompt dialog box and clicks a button.
Parameters
text<str>: The content to input.
option <str> The input box to click.
Options:
ok: Clicks the OK button.
cancel: Clicks the Cancel button.
element<str>: The control. If this parameter is not specified, the method clicks a button in a pop-up box within the browser.
simulate<bool>: Specifies whether to simulate the action.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<Element>: The parent control object.
timeout<int>: The timeout period, in seconds.
Example: rpa.app.chrome.ChromeTab.process_prompt
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. This method can only handle prompt pop-ups.
# The following is a code example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.chrome.create(url)
page.execute_js('prompt("Please enter content:","")')
page.process_prompt('RPA_TEST')pos
pos(element, index=1, parent_element=None, timeout=10)
Description
Retrieves the coordinates of a control.
Parameters
element<str>: The control.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<str>: The parent control object.
timeout<int>: The timeout period, in seconds.
The control must be visible on the screen. You may need to use the following methods:
The browser tab must be active. You can use the activate method.
Use the scroll_into_view or scroll method to scroll the page.
Example: rpa.app.chrome.ChromeTab.pos
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. This method returns the coordinates of the page element relative to the top-left corner of the screen. This means the coordinates change if you move the browser window.
# The following is a code example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.chrome.create(url)
pos = page.pos('logon_button-chrome')screenshot
screenshot(element, file, index=1, parent_element=None, timeout=10)
Description
Takes a screenshot of a control.
Parameters
element<str>: The control.
file<str>: The path to save the screenshot.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<str>: The parent control object.
timeout<int>: The timeout period, in seconds.
The control must be visible on the screen. You may need to use the following methods:
The browser tab must be active. You can use the activate method.
Use the scroll_into_view or scroll method to scroll the page.
Example: rpa.app.chrome.ChromeTab.screenshot
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. Before use, confirm that the page elements have been recorded using the control capturing feature.
# The following is a code example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.chrome.create(url)
save_path = r'D:\aliyun_footer_screenshot.jpg'
page.screenshot('webpage_footer-presales_consulting-chrome',save_path)mouse_move
mouse_move(element, index=1, parent_element=None, timeout=10)
Description
Moves the mouse pointer over a control.
Parameters
element<str>: The control.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<str>: The parent control object.
timeout<int>: The timeout period, in seconds.
Example: rpa.app.chrome.ChromeTab.mouse_move
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. Before use, confirm that the page elements have been recorded using the control capturing feature.
# The following is a code example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.chrome.create(url)
page.mouse_move('webpage_footer-presales_consulting-chrome')isvisible
isvisible(element, index=1, parent_element=None, timeout=10)
Description
Checks whether a control is visible.
Parameters
element<str>: The control.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<str>: The parent control object.
timeout<int>: The timeout period, in seconds.
Return value
Returns a <bool> that indicates whether the control is visible.
Example: rpa.app.chrome.ChromeTab.isvisible
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. Before use, confirm that the page elements have been recorded using the control capturing feature.
# 3. This method checks the visibility property of a page element. If the element does not exist on the page, a "control not found" timeout exception is thrown.
# The following is a code example. In this example, after opening the webpage, JavaScript is used to set the specified page element to be invisible, and then this method is used.
url = 'www.baidu.com'
page = rpa.app.chrome.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-chrome')drag
drag(element, x=0, y=0,speed_mode='uniform', index=1, parent_element=None, timeout=10)
Description
Drags a control by a specified offset.
Parameters
element<str>: The control.
x<int>: The horizontal offset.
y<int>: The vertical offset.
speed_mode<str>: The speed mode for dragging.
uniform: Drags at a uniform speed.
fast-slow-pause: Simulates human-like dragging behavior by accelerating, decelerating, and then pausing.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<str>: The parent control object.
timeout<int>: The timeout period, in seconds.
Example: rpa.app.chrome.ChromeTab.drag
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. Before use, confirm that the page elements have been recorded using the control capturing feature.
# The following is a code example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.chrome.create(url)
page.drag('logon_button-chrome',x=-500,y=100)(Deprecated) clear_input
clear_input(element, index=1, parent_element=None, timeout=10)
Description
Clears the content of an input box.
For client versions 4.10.3.1033 and later, we recommend using clear_input_simulated or clear_input_directed.
This method is still functional. Automation flows that use this method are not affected.
Parameters
element<str>: The name of the control.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<str>: The parent control object.
timeout<int>: The timeout period for finding the control, in seconds.
Example: rpa.app.chrome.ChromeTab.clear_input
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. Before use, confirm that the page elements have been recorded using the control capturing feature.
# The following is a code example:
url = 'www.aliyun.com'
page = rpa.app.chrome.create(url)
page.clear_input('search-input')clear_input_simulated
clear_input_simulated(element, index=1, parent_element=None, mode = 'native', timeout=10):
Description
Clears the content of an input box using simulation.
This feature is available in client versions 4.10.3.1033 and later.
Parameters
element<str>: The name of the control.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<str>: The parent control object.
mode<str>: The input method. Valid values are native, cdp, and driver.
native: Uses the operating system interface to clear the content.
cdp: Uses a browser plug-in to simulate clearing the content.
driver: Uses a driver to simulate keyboard actions to clear the content.
ImportantFor more information about the limitations, see Driver input limits.
timeout<int>: The timeout period for finding the control, in seconds.
Example: rpa.app.chrome.ChromeTab.clear_input_simulated
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. Before use, confirm that the page elements have been recorded using the control capturing feature.
# The following is a code example:
# 1. First, enter text content.
# 2. Call this method to clear the entered content.
url = 'www.aliyun.com'
page = rpa.app.chrome.create(url)
page.input_text_simulated('search-input','Alibaba Cloud RPA')
page.clear_input_simulated('search-input')clear_input_directed
clear_input_directed(element, index=1, parent_element=None, timeout=10)
Description
Clears the content of an input box by modifying HTML attributes.
This feature is available in client versions 4.10.3.1033 and later.
This method is fast but may not work on all webpages due to their frontend implementation.
We recommend that you use clear_input_simulated.
Parameters
element<str>: The name of the control.
index<int>: If multiple controls match, this parameter specifies the index of the target control.
parent_element<str>: The parent control object.
timeout<int>: The timeout period for finding the control, in seconds.
Example: rpa.app.chrome.ChromeTab.clear_input_directed
# Notes:
# 1. This method requires the Aliyun RPA Chrome extension to be installed and enabled.
# 2. Before use, confirm that the page elements have been recorded using the control capturing feature.
# The following is a code example:
# 1. First, enter text content.
# 2. Call this method to clear the entered content.
url = 'www.aliyun.com'
page = rpa.app.chrome.create(url)
page.input_text_simulated('search-input','Alibaba Cloud RPA')
page.clear_input_directed('search-input')