close
close()
Description
Closes the IETab object.
Example: rpa.app.ie.IETab.close
# Note: Call this method on an IETab instance object.
# The following is a sample code:
page = rpa.app.ie.create('www.taobao.com')
page.close()navigate
navigate(url, wait=True, timeout=100)
Description
Navigates to the specified URL.
Parameters
url<str> The URL to navigate to.
wait<bool> Set to True to wait for the page to load. The default is True.
timeout<int> The timeout in seconds. The default is 100.
Example: rpa.app.ie.IETab.navigate
# Note: Call this method on an IETab instance object.
# The following is a sample code:
page = rpa.app.ie.create('www.taobao.com')
page.navigate('www.aliyun.com')back
back(wait=True, timeout=100)
Description
Navigates to the previous page in the browser history.
Parameters
wait<bool> Set to True to wait for the page to load. The default is True.
timeout<int> The timeout in seconds. The default is 100.
Example: rpa.app.ie.IETab.back
# Note: Call this method on an IETab instance object.
# The following is a sample code:
page = rpa.app.ie.create('www.taobao.com')
page.navigate('www.aliyun.com')
page.back()forward
forward(wait=True, timeout=100)
Description
Navigates to the next page in the browser history.
Parameters
wait<bool> Set to True to wait for the page to load. The default is True.
timeout<int> The timeout in seconds. The default is 100.
Example: rpa.app.ie.IETab.forward
# Note: Call this method on an IETab instance object.
# The following is a sample code:
page = rpa.app.ie.create('www.taobao.com')
page.navigate('www.aliyun.com')
page.back()
page.forward()get_cookies
get_cookies()
Description
Gets the cookies for the current page.
Returns
Returns a list of cookies.<list>
Example: rpa.app.ie.IETab.get_cookies
# Note: Call this method on an IETab instance object.
# The following is a sample code:
page = rpa.app.ie.create('www.taobao.com')
cookies = page.get_cookies()wait_loaded
wait_loaded(element, index=1, parent_element=None, timeout=10, ignore_error=True)
Description
Waits for an element to be loaded on the page.
Parameters
element<str> The target element.
index<int> The 1-based index of the element if multiple matches are found.
timeout<int> The timeout in seconds.
parent_element<Element> The parent element.
ignore_error<bool> If True, errors are ignored when the element is not found within the timeout period.
Example: rpa.app.ie.IETab.wait_loaded
# Note: Call this method on an IETab instance object. Before use, capture the target page element.
# The following is a sample code:
page = rpa.app.ie.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 an element to disappear from the page.
Parameters
element<str> The target element.
index<int> The 1-based index of the element if multiple matches are found.
timeout<int> The timeout in seconds.
parent_element<Element> The parent element.
Example: rpa.app.ie.IETab.wait_disappear
# Note: Call this method on an IETab instance object. Throws an exception if the element does not disappear within the specified timeout.
# The following is a sample code:
page = rpa.app.ie.create('www.taobao.com')
flag = page.wait_disappear('taobao_logo')download_by_url
download_by_url(url, path, wait=True, complete_timeout=120)
Description
Downloads a file from a specified URL.
Parameters
url<str> The URL of the file to download.
path<str> The file path to save the downloaded file.
complete_timeout<int> The timeout in seconds.
wait<bool> Set to True to wait for the download to complete.
Example: rpa.app.ie.IETab.download_by_url
# Note: Call this method on an IETab instance object.
# The following example downloads the specified file to the designated path.
page = rpa.app.ie.create('www.cninfo.com.cn')
download_url = '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)download_by_element
download_by_element(path, element, index=1, parent_element=None, wait=True, suffix=None, complete_timeout=120)
Description
Downloads a file by clicking an element.
Parameters
path<str> The file path to save the downloaded file.
element<str> The target element.
index<int> The 1-based index of the element if multiple matches are found.
parent_element<Element> The parent element.
complete_timeout<int> The timeout in seconds.
wait<bool> Set to True to wait for the download to complete.
suffix<str>The filename suffix format.
Options:
datetime: Appends the date and time (YYYYMMDDHHMM).date: Appends the date (YYYYMMDD).
Example: rpa.app.ie.IETab.download_by_element
# Note: Call this method on an IETab instance object. Before use, capture the download button element on the page and verify that it works.
# The following example downloads the specified file to the designated path.
url = 'http://www.cninfo.com.cn/new/disclosure/detail?plate=hke&orgId=9900042435&stockCode=09988&announcementId=1209275224'
page = rpa.app.ie.create(url)
download_path = r'D:\Alibaba-SW-Public-Data.pdf'
page.download_by_element(download_path,'announcement_download_ie')upload
upload(element, file, index=1, parent_element=None, timeout=10)
Description
Uploads a file.
Parameters
file<str> The file path of the file to upload.
element<str> The target element, which is typically a file input or upload button.
index<int> The 1-based index of the element if multiple matches are found.
parent_element<Element> The parent element.
timeout<int> The timeout in seconds.
Example: rpa.app.ie.IETab.upload
# Note: Call this method on an IETab instance object. Before use, capture the upload button element on the page and verify that it works.
# The following example uploads the specified image file.
url = 'https://duguang.aliyun.com/experience?type=standard&subtype=idcard#intro'
page = rpa.app.ie.create(url)
upload_path = r'D:\2_Test_File_Archive\OCR_ID_Card_Recognition.jpg'
page.upload('upload_image_ie',upload_path)execute_js
execute_js(code, timeout=10)
Description
Executes JavaScript on the page.
Parameters
code<str> The JavaScript code to execute.
timeout<int> The timeout in seconds.
Example: rpa.app.ie.IETab.execute_js
# Note: Call this method on an IETab instance object. To get a return value, use a 'return' statement in your JavaScript function.
# The following example creates an IETab object and executes a script on that page.
page = rpa.app.ie.create('www.baidu.com')
js_code = """
function test(){
var div1 = document.getElementById("su").getAttribute('%s');
return(div1)
} ;
result = test() ;
console.log(result) ;
alert(result);
return result;
"""%'value'
value = page.execute_js(js_code)
print(value)table
table(element, return_type='text', index=1, parent_element=None, timeout=10)
Description
Extracts data from a table element.
Parameters
return_type<str> The return type.
Options:
text: Returns the table content as text.html: Returns the table's outer HTML.
index<int> The 1-based index of the element if multiple matches are found.
parent_element<Element> The parent element.
timeout<int> The timeout in seconds.
Returns
Returns a 2D array (as a list of lists) or an HTML string.<list>
Example: rpa.app.ie.IETab.table
# Note: Call this method on an IETab instance object. Before use, capture a standard table element (with the `<table>` HTML tag) on the page.
# The following is a sample code:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
table_data = page.table('table-ie')scroll
scroll(height, element=None, index=1, parent_element=None, timeout=10, direction='top')
Description
Scrolls the page, or the scrollbar within a specified element.
Parameters
element<str> The target element.
index<int> The 1-based index of the element if multiple matches are found.
parent_element<Element> The parent element.
timeout<int> The timeout in seconds.
height<int> The height in pixels to scroll.
direction<str> The scroll direction.
Options:
left: Scrolls left.top: Scrolls down (towards the bottom of the page).
Returns
Returns True if more scrolling is possible, or False if the end of the scrollable area is reached.<bool>
Example: rpa.app.ie.IETab.scroll
# Note: Call this method on an IETab instance object.
# The following example scrolls the opened page down by 500 pixels.
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
page.scroll(500)
# To scroll a list within the page, you must pass the height and element parameters. For example:
page.scroll(200, element='list_scroll_bar', index=1, parent_element=None, timeout=10, direction='top')
Capture the scrollable list area itself, not its scrollbar.
scroll_into_view
scroll_into_view(element, index=1, parent_element=None, timeout=10)
Description
Scrolls an element into the visible area.
Parameters
element<str> The target element.
index<int> The 1-based index of the element if multiple matches are found.
parent_element<Element> The parent element.
timeout<int> The timeout in seconds.
Example: rpa.app.ie.IETab.scroll_into_view
# Note: Call this method on an IETab instance object. Before use, capture the target page element.
# The following example scrolls the page down until the specified element is within the visible area.
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
page.scroll_into_view('page_footer-ie')get_scroll_height
get_scroll_height(element=None, index=1, parent_element=None, timeout=10)
Description
Gets the height of the vertical scrollbar. If an element is specified, gets the scroll height of that element.
Parameters
element<str> The target element.
Returns
The height of the vertical scrollbar.<str>
Example: rpa.app.ie.IETab.get_scroll_height
# Note: Call this method on an IETab instance object.
# The following example gets the current vertical scroll position of the page.
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
height = page.get_scroll_height()get_scroll_width
get_scroll_width(element=None, index=1, parent_element=None, timeout=10)
Description
Gets the width of the horizontal scrollbar. If an element is specified, gets the scroll width of that element.
Parameters
element<str> The target element.
Returns
The width of the horizontal scrollbar.<str>
Example: rpa.app.ie.IETab.get_scroll_width
# Note: Call this method on an IETab instance object.
# The following example gets the current horizontal scroll position of the page.
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
height = page.get_scroll_width()text
text(element=None, index=1, parent_element=None, timeout=10)
Description
Gets the text content of an element.
Parameters
element<str> The target element.
index<int> The 1-based index of the element if multiple matches are found.
parent_element<Element> The parent element.
timeout<int> The timeout in seconds.
Returns
The text content. If no element is specified, returns all text from the page.<str>
Example: rpa.app.ie.IETab.text
# Note: Call this method on an IETab instance object. To get the text of a specific element, you must capture the element first.
# The following is a sample code:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
text = page.text(element='page_footer-ie')html
html(element=None, index=1, parent_element=None, timeout=10)
Description
Gets the HTML content of an element.
Parameters
element<str> The target element.
index<int> The 1-based index of the element if multiple matches are found.
parent_element<Element> The parent element.
timeout<int> The timeout in seconds.
Returns
The HTML content. If no element is specified, returns the HTML of the entire page.<str>
Example: rpa.app.ie.IETab.html
# Note: Call this method on an IETab instance object. To get the HTML of a specific element, you must capture the element first.
# The following is a sample code:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
html = page.html('page_footer-ie')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 into an element.
Parameters
element<str> The target element.
index<int> The 1-based index of the element if multiple matches are found.
value<str> The text to input.
parent_element<Element> The parent element.
simulate<bool> Set to True to simulate user typing.
replace<bool> Set to True to clear existing content before inputting text.
sent_raw<bool> Set to True to send raw keystrokes. This parameter is only effective when simulate is False.
wait_mili_seconds<int> The delay, in milliseconds, between keystrokes. This parameter is only effective when simulate is True. The default is 20, and the maximum is 100. A high value may cause a timeout.
timeout<int> The timeout in seconds.
Example: rpa.app.ie.IETab.input_text
# Note: Call this method on an IETab instance object. Before use, capture the input box element on the page.
# The following is a sample code:
url = 'www.taobao.com'
page = rpa.app.ie.create(url)
page.input_text('taobao_search_box-ie','RPA')input_hotkeys
input_hotkeys(element, value, index=1, parent_element=None, timeout=10)
Description
Inputs a hotkey. For details, see input_hotkey Usage and Virtual Key Code List.
Parameters
element<str> The target element.
value<str> The virtual key code.
index<int> The 1-based index of the element if multiple matches are found.
parent_element<Element> The parent element.
timeout<int> The timeout in seconds.
value
value(element, index=1, parent_element=None, timeout=10)
Description
Gets the value of an element, which is typically from an input field.
Parameters
element<str> The target element.
index<int> The 1-based index of the element if multiple matches are found.
parent_element<Element> The parent element.
timeout<int> The timeout in seconds.
Returns
The value of the element.<str>
Example: rpa.app.ie.IETab.value
# Note: Call this method on an IETab instance object. Before use, capture the page element.
# The following is a sample code:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
value = page.value('page_footer-ie')option
option(element, text, type='match', index=1, parent_element=None, clear_selected=False, timeout=10)
Description
Selects an option in a drop-down list by its text.
Parameters
element<str> The target element.
index<int> The 1-based index of the element if multiple matches are found.
text<str> The text of the option to select.
parent_element<Element> The parent element.
type<str> The match type.
Options:
match:partial match.full:full match.regex:regex match.
clear_selected<bool> Specifies whether to clear previously selected options. This parameter applies only to multi-select drop-down lists.
timeout<int> The timeout in seconds.
Example: rpa.app.ie.IETab.option
# Note:
# 1. Call this method on an IETab instance object. Before use, capture a standard drop-down list element (with the `` HTML tag).
# 2. Ensure that the drop-down list contains the specified text option.
# The following is a sample code:
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
page = rpa.app.ie.create(url)
page.option('drop_down_list-ie','00:00--06:00')option_by_indexoption_by_index(element, item_index, index=1, parent_element=None, clear_selected=False, timeout=10)DescriptionSelects an option in a drop-down list by its index.Parameterselement<str> The target element.index<int> The 1-based index of the element if multiple matches are found.item_index<int> The 1-based index of the option to select.parent_element<Element> The parent element.clear_selected<bool> Specifies whether to clear previously selected options. This parameter applies only to multi-select drop-down lists.timeout<int> The timeout in seconds.Example: rpa.app.ie.IETab.option_by_index# Note:
# 1. Call this method on an IETab instance object. Before use, capture a standard drop-down list element (with the `` HTML tag).
# 2. Confirm the number of options in the drop-down list. The index starts from 1 and must not exceed the total number of options.
# The following is a sample code:
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
page = rpa.app.ie.create(url)
page.option_by_index('drop_down_list-ie',4)option_by_index
option_by_index(element, item_index, index=1, parent_element=None, clear_selected=False, timeout=10)
Method Description
Select from the index drop-down list.
Parameter descriptions
element<str>Control
index<int> Specifies the element index if multiple are found.
item_index<int> The index of the item
parent_element<Element>The parent element.
clear_selected<bool> Whether to clear the previous selection (applies only to multiple selections)
timeout<int>The timeout period.
Example- rpa.app.ie.IETab.option_by_index-
# Notes:
# 1. This method can only be used on an IETab instance object. Before you use this method, you must use the element capture feature to obtain the standard drop-down list element (which is an HTML `select` tag) from the page.
# 2. You must confirm the number of options in the drop-down list. The index is 1-based and cannot exceed the maximum number of options.
# The following is a code example:
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
page = rpa.app.ie.create(url)
page.option_by_index('drop-down-list-ie',4)get_options
get_options(element, mode='all', index=1, parent_element=None, timeout=10)
Description
Returns the selected or all options from a drop-down list.
Parameters
element<str> The target element.
mode<str> The return type.
Options:
selected: Returns only the selected options.all: Returns all options.
index<int> The 1-based index of the element if multiple matches are found.
parent_element<Element> The parent element.
timeout<int> The timeout in seconds.
Returns
A list of options.<list>
Example: rpa.app.ie.IETab.get_options
# Note: Call this method on an IETab instance object. Before use, capture a standard drop-down list element (with the `` HTML tag).
# The following is a sample code:
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
page = rpa.app.ie.create(url)
options = page.get_options('drop_down_list-ie')get_checked_stateget_checked_state(element, index=1, parent_element=None, timeout=10)DescriptionGets the checked state of a checkbox or radio button.Parameterselement<str> The target element.index<int> The 1-based index of the element if multiple matches are found.parent_element<Element> The parent element.timeout<int> The timeout in seconds.ReturnsThe checked state.<bool>Example: rpa.app.ie.IETab.get_checked_state# Note: Call this method on an IETab instance object. Before use, capture the checkbox element on the page.
# The following is a sample code:
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
page = rpa.app.ie.create(url)
check_state = page.get_checked_state('checkbox-ie')set_checked_stateset_checked_state(element, value=True, index=1, parent_element=None, timeout=10)DescriptionSets the state of a checkbox or radio button.Parameterselement<str> The target element.index<int> The 1-based index of the element if multiple matches are found.value<bool> Set to True to check the box, or False to uncheck it.parent_element<Element> The parent element.timeout<int> The timeout in seconds.Example: rpa.app.ie.IETab.set_checked_state# Note: Call this method on an IETab instance object. Before use, capture the checkbox element on the page.
# The following is a sample code:
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
page = rpa.app.ie.create(url)
page.set_checked_state('checkbox-ie')clickclick(element, index=1, parent_element=None, simulate=True, button='left', timeout=10)DescriptionClicks an element.Parameterselement<str> The target element.index<int> The 1-based index of the element if multiple matches are found.parent_element<Element> The parent element.simulate<bool> Set to True to simulate a user click.button<str> The mouse button to use.Options:left: Left mouse button.right: Right mouse button.timeout<int> The timeout in seconds.Example: rpa.app.ie.IETab.click# Note:
# 1. Call this method on an IETab instance object. Before use, capture the clickable element on the page.
# 2. If `simulate` is `True`, the `element` must be in the `visible area` for the click to succeed.
# 3. If `simulate` is `False`, a click event is sent directly to the `element`, regardless of its visibility.
# The following is a sample code:
url = 'www.aliyun.com'
page = rpa.app.ie.create(url)
page.click('login_button-ie')double_clickdouble_click(element, index=1, parent_element=None, simulate=True, timeout=10)DescriptionDouble-clicks an element.Parameterselement<str> The target element.index<int> The 1-based index of the element if multiple matches are found.parent_element<Element> The parent element.simulate<bool> Set to True to simulate a user double-click.timeout<int> The timeout in seconds.Example: rpa.app.ie.IETab.double_click# Note:
# 1. Call this method on an IETab instance object. Before use, capture the clickable element on the page.
# 2. If `simulate` is `True`, the `element` must be in the `visible area` for the double-click to succeed.
# 3. If `simulate` is `False`, a double-click event is sent directly to the `element`, regardless of its visibility.
# The following is a sample code:
url = 'www.aliyun.com'
page = rpa.app.ie.create(url)
page.double_click('login_button-ie')countcount(element, parent_element=None)DescriptionCounts the number of matching elements on the page.Parameterselement<str> The target element.parent_element<Element> The parent element.ReturnsThe number of matching elements.<int>Example: rpa.app.ie.IETab.count# Note: Call this method on an IETab instance object. Before use, capture the page element.
# This method is often used to count similar elements after they have been captured.
# The following is a sample code:
url = 'www.aliyun.com'
page = rpa.app.ie.create(url)
page.count('login_button-ie')hrefhref(element, index=1, parent_element=None, timeout=10)DescriptionGets the URL from an element's href attribute.Parameterselement<str> The target element.index<int> The 1-based index of the element if multiple matches are found.parent_element<Element> The parent element.timeout<int> The timeout in seconds.ReturnsThe URL from the href attribute.<str>Example: rpa.app.ie.IETab.href# Note: Call this method on an IETab instance object. Before use, capture an element that has an `href` attribute.
# The following is a sample code:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
link = page.href('login_button-ie')process_alertprocess_alert(option='ok', element=None, simulate=True, index=1, parent_element=None, timeout=10)DescriptionHandles a popup by clicking a button.Parametersoption<str> The action to take on the popup.Options:ok: Clicks the OK button.cancel: Clicks the Cancel button.element<str> The target element. If not specified, handles the browser's native popup.simulate<bool> Set to True to simulate user interaction.index<int> The 1-based index of the element if multiple matches are found.parent_element<Element> The parent element.timeout<int> The timeout in seconds.Example: rpa.app.ie.IETab.process_alert# Note:
# 1. Call this method on an IETab instance object.
# 2. This method can only handle `confirm` or `alert` popups.
# The following is a sample code:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
page.execute_js('alert("This is a popup")')
page.process_alert()process_promptprocess_prompt(text, option='ok', element=None, simulate=True, index=1, parent_element=None, timeout=10)DescriptionInputs text into a prompt popup and clicks a button.Parameterstext<str> The text to input.option<str> The action to take on the popup.Options:ok: Clicks the OK button.cancel: Clicks the Cancel button.element<str> The target element. If not specified, handles the browser's native popup.simulate<bool> Set to True to simulate user interaction.index<int> The 1-based index of the element if multiple matches are found.parent_element<Element> The parent element.timeout<int> The timeout in seconds.Example: rpa.app.ie.IETab.process_prompt# Note:
# 1. Call this method on an IETab instance object.
# 2. This method can only handle `prompt` popups.
# The following is a sample code:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
page.execute_js('prompt("Please enter some text:","")')
page.process_prompt('RPA_TEST')alert_messagealert_message()DescriptionGets the message from a popup.ReturnsThe message from the popup.<str>Example: rpa.app.ie.IETab.alert_message# Note:
# 1. Call this method on an IETab instance object.
# 2. This method can only handle `prompt` popups.
# The following is a sample code:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
page.execute_js('alert("Alibaba Cloud RPA_TEST")')
message = page.alert_message()pospos(element, index=1, parent_element=None, timeout=10)DescriptionGets the screen coordinates of an element.Parameterselement<str> The target element.index<int> The 1-based index of the element if multiple matches are found.parent_element<Element> The parent element.timeout<int> The timeout in seconds.ReturnsThe coordinates.<dict>Example: rpa.app.ie.IETab.pos# Note:
# 1. Call this method on an IETab instance object. Before use, capture the page element.
# 2. Returns the element's coordinates relative to the top-left corner of the screen. These coordinates change if you move the browser window.
# The following is a sample code:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
pos = page.pos('login_button-ie')screenshotscreenshot(element, file, index=1, parent_element=None, timeout=10)DescriptionTakes a screenshot of an element.Parameterselement<str> The target element.file<str> The file path to save the screenshot.index<int> The 1-based index of the element if multiple matches are found.parent_element<Element> The parent element.timeout<int> The timeout in seconds.Example: rpa.app.ie.IETab.screenshot# Note:
# 1. Call this method on an IETab instance object. Before use, capture the page element.
# 2. This method automatically scrolls the target element into the visible area.
# The following example takes a screenshot of the specified element and saves it to the designated path.
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
save_path = r'D:\Alibaba_Cloud_Footer_Screenshot.jpg'
page.screenshot('page_footer-ie',save_path)mouse_movemouse_move(element, index=1, parent_element=None, timeout=10)DescriptionMoves the mouse cursor over an element.Parameterselement<str> The target element.index<int> The 1-based index of the element if multiple matches are found.parent_element<Element> The parent element.timeout<int> The timeout in seconds.Example: rpa.app.ie.IETab.mouse_move# Note:
# 1. Call this method on an IETab instance object. Before use, capture the page element.
# 2. This method automatically scrolls to bring the target element into the visible area.
# The following example moves the mouse cursor over the specified element.
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
page.mouse_move('page_footer-ie')dragdrag(element, x=0, y=0,speed_mode='uniform', index=1, parent_element=None, timeout=10)DescriptionDrags an element by a specified offset.Parameterselement<str> The target element.x<int> The horizontal offset in pixels.y<int> The vertical offset in pixels.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 1-based index of the element if multiple matches are found.parent_element<Element> The parent element.timeout<int> The timeout in seconds.Example: rpa.app.ie.IETab.drag# Note: Call this method on an IETab instance object. Before use, capture the page element.
# The following is a sample code:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
page.drag('login_button-ie',x=-500,y=100)get_element_by_nameget_element_by_name(element, index=1, parent_element=None, timeout=10)DescriptionGets an element by its name.Parameterselement<str> The name of the target element.index<int> The 1-based index of the element if multiple matches are found.parent_element<Element> The parent element.timeout<int> The timeout in seconds.ReturnsThe matching element object.<Element>Example: rpa.app.ie.IETab.get_element_by_name# Note: Call this method on an IETab instance object. Before use, capture the page element.
# The following is a sample code:
url = 'https://www.baidu.com/'
page = rpa.app.ie.create(url)
element = page.get_element_by_name('baidu_search_button-ie')
text = element.text()get_element_by_cssget_element_by_css(css, index=1, parent_element=None, timeout=10)DescriptionGets an element using a CSS selector.Parameterscss<str> The CSS selector.index<int> The 1-based index of the element if multiple matches are found.parent_element<Element> The parent element.timeout<int> The timeout in seconds.ReturnsThe matching element object.<Element>Example: rpa.app.ie.IETab.get_element_by_css# Note:
# 1. Call this method on an IETab instance object.
# 2. This method locates an element using a standard CSS selector.
# The following is a sample code:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
css_selector = "span.menu-title-text"
element = page.get_element_by_css(css_selector)
text = element.text()urlurl()DescriptionGets the URL of the current page.ReturnsThe current URL.<str>Example: rpa.app.ie.IETab.url# Note: Call this method on an IETab instance object.
# The following is a sample code:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
get_url = page.url()titletitle()DescriptionGets the title of the current page.ReturnsThe page title.<str>Example: rpa.app.ie.IETab.title# Note: Call this method on an IETab instance object.
# The following is a sample code:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
title= page.title()reloadreload(wait=True, timeout=100)DescriptionReloads the current page.Parameterswait<bool> Set to True to wait for the page to finish loading.timeout<int> The timeout in seconds. The default is 100.Example: rpa.app.ie.IETab.reload# Note: Call this method on an IETab instance object.
# The following is a sample code:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
page.reload()attrattr(element, name, index=1, parent_element=None, timeout=10)DescriptionGets the value of an attribute for a specified element.Parameterselement<str> The target element.name<str> The name of the attribute.index<int> The 1-based index of the element if multiple matches are found.parent_element<Element> The parent element.timeout<int> The timeout in seconds.ReturnsThe attribute value.<str>Example: rpa.app.ie.IETab.attr# Note: Call this method on an IETab instance object.
# The following is a sample code:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
attribute = page.attr('login_button-ie','class')in_viewin_view(element, index=1, parent_element=None, timeout=10)DescriptionChecks if an element is in the visible area.Parameterselement<str> The target element.index<int> The 1-based index of the element if multiple matches are found.parent_element<Element> The parent element.timeout<int> The timeout in seconds.ReturnsReturns True if the element is in the visible area; otherwise, returns False.<bool>Example: rpa.app.ie.IETab.in_view# Note: Call this method on an IETab instance object. Before use, capture the page element.
# The following example checks if the specified element is visible on the page.
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
flag = page.in_view('login_button-ie')Get checked state
get_checked_state(element, index=1, parent_element=None, timeout=10)
Method Description
Get checked state
Parameter description
element<str>element
index<int> If multiple elements exist, specify the element index.
parent_element<Element>The parent element.
timeout<int>Timeout period
Return value description
Returns the checked state <bool>
Example- rpa.app.ie.IETab.get_checked_state-
# Note: This method operates only on IETab instance objects. Before use, you must obtain the checkbox element by using the capture element feature.
# Sample code:
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
page = rpa.app.ie.create(url)
check_state = page.get_checked_state('checkbox-ie')Set checked state
set_checked_state(element, value=True, index=1, parent_element=None, timeout=10)
Method description
Checkbox operations
Parameters
element<str>element
index<int> If multiple elements exist, specify the index of the element.
value<bool> Set to True to check the option, or False to uncheck it
parent_element<Element>The parent element.
timeout<int>The timeout period.
Example Call- rpa.app.ie.IETab.set_checked_state-
# Note: This method works only with IETab instance objects. Before using it, you must first obtain the checkbox element on the page by using the element capturing feature.
# Code example:
url = 'https://kyfw.12306.cn/otn/leftTicket/init'
page = rpa.app.ie.create(url)
page.set_checked_state('checkbox-ie')Click
click(element, index=1, parent_element=None, simulate=True, button='left', timeout=10)
Method Description
Click
Parameter description
element<str>Element
index<int>If multiple elements are found, specify the element index.
parent_element<Element>The parent element.
simulate<bool>Whether to simulate a click
button<str> Mouse button
Optional:
left: Left button
right: Right button
timeout<int> The timeout period.
Example- rpa.app.ie.IETab.click-
# Notes:
# 1. This method operates only on IETab instance objects. Before use, you must obtain the clickable elements on the page by using the capture element feature.
# 2. If simulate=True, a simulated click is performed. The target page element must be within the visible area for the mouse click to be simulated.
# 3. If simulate=False, a non-simulated click is performed, and a click command is sent directly to the element.
# The following code shows an example call:
url = 'www.aliyun.com'
page = rpa.app.ie.create(url)
page.click('login_button-ie')Double click
double_click(element, index=1, parent_element=None, simulate=True, timeout=10)
Method description
double-click
Parameter description
element<str>Control
index<int> If there are multiple, specify the element index.
parent_element<Element>parent element
simulate<bool>Specifies whether to simulate a click.
timeout <int> The timeout period.
Example- rpa.app.ie.IETab.double_click-
# Notes:
# 1. This method can be used only on IETab instance objects. Before you use this method, you must use the capture element feature to obtain a clickable element on the page.
# 2. If simulate is set to True, a simulated click is performed. The corresponding page element must be in the visible area to simulate a mouse click.
# 3. If simulate is set to False, a non-simulated click is performed, and a click command is sent directly to the element.
# The following provides a code example:
url = 'www.aliyun.com'
page = rpa.app.ie.create(url)
page.double_click('login_button-ie')Count
count(element, parent_element=None)
Method Description
Getting the element count
Parameters
element <str> The UI element
parent_element<Element>The parent element.
Return value description
Return count<int>
Example - rpa.app.ie.IETab.count-
# Note: This method can only operate on IETab instance objects. Before using this method, you must use the capture element feature to obtain the elements on the page.
# This method is often used to count the number of elements after you obtain similar element objects by using the capture similar elements feature.
# The following is a code sample:
url = 'www.aliyun.com'
page = rpa.app.ie.create(url)
page.count('login_button_ie')href
href(element, index=1, parent_element=None, timeout=10)
Description
Get link
Parameter descriptions
element<str>element
index<int> If more than one element is found, specify its index.
parent_element<Element>The parent element.
timeout<int>Timeout period
Return value description
Returned link<str>
Example - rpa.app.ie.IETab.href-
# Note: This method can only be used with IETab instance objects. Before you use this method, you must use the element capturing feature to obtain an element that has an href attribute from the page.
# Code sample:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
link = page.href('login_button-ie')process_alert
process_alert(option='ok', element=None, simulate=True, index=1, parent_element=None, timeout=10)
Method description
Click in the popup.
Parameter description
option<str>Popup handling
Optional:
ok: Click OK
cancel: Click Cancel
element<str>The element to be clicked (if omitted, the click is performed on a browser popup).
simulate<bool> Whether to simulate.
index <int> If there are multiple, specify the index of the element.
parent_element<Element>parent element
timeout<int>Timeout value
Example- rpa.app.ie.IETab.process_alert-
# Notes:
# 1. This method can only be used with IETab instance objects.
# 2. This method can only handle confirm or alert pop-ups.
# Sample code:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
page.execute_js('alert("Alert box")')
page.process_alert()process_prompt
process_prompt(text, option='ok', element=None, simulate=True, index=1, parent_element=None, timeout=10)
Description
Enter text in the input box and click.
Parameters
text<str> The content to enter.
option<str>Popup handling
Optional:
ok: Click OK
cancel: Click Cancel
element<str>The element. If omitted, the operation defaults to a click on a browser popup.
simulate<bool>Specifies whether to simulate the operation.
index<int> If multiple elements are found, specify the index of the element.
parent_element<Element> parent element
timeout<int>The timeout period.
Sample Call- rpa.app.ie.IETab.process_prompt-
# Notes:
# 1. This method can only operate on IETab instance objects.
# 2. This method can only handle prompt dialogs.
# Code sample:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
page.execute_js('prompt("Enter the content:","")')
page.process_prompt('RPA_TEST')alert_message
alert_message()
Method description
Obtain the popup message
Return value description
Returns the popup message <str>
Usage Example- rpa.app.ie.IETab.alert_message-
# Notes:
# 1. This method can only be used with IETab instance objects.
# 2. This method can only handle alert pop-ups.
# The following is a code sample:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
page.execute_js('alert("Alibaba Cloud RPA_TEST")')
message = page.alert_message()Pos
pos(element, index=1, parent_element=None, timeout=10)
Method Description
Obtain Element Coordinates
Parameter description
element<str>Control
index<int>Specifies the index of the element to use if multiple are present.
parent_element<Element>The parent element.
timeout<int>Timeout period
Return Values
Returns coordinates<dict>
Example - rpa.app.ie.IETab.pos-
# Notes:
# 1. This method can be used only on IETab instance objects. Before you use this method, you must use the capture element feature to obtain the elements on the page.
# 2. The coordinates returned by this method are relative to the top-left corner of the screen. These coordinates change if you move the web page window.
# The following code provides an example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
pos = page.pos('Login Button-ie')Screenshot
screenshot(element, file, index=1, parent_element=None, timeout=10)
Method Description
Screenshot
Parameter descriptions
element<str>Control
file<str>The path where the screenshot is saved.
index<int>If there is more than one element, specify its index.
parent_element<Element>The parent element.
timeout <int> Timeout period
Usage Example - rpa.app.ie.IETab.screenshot-
# Notes:
# 1. This method operates only on IETab instance objects. Before you use this method, you must obtain the page elements by using the element capturing feature.
# 2. This method automatically scrolls the page to bring the target element into the visible area.
# The following code sample shows how to take a screenshot of a page element and save the screenshot to a specified path.
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
save_path = r'D:\alibaba_cloud_bottom_text_screenshot.jpg'
page.screenshot('webpage_bottom-ie', save_path)mouse_move
mouse_move(element, index=1, parent_element=None, timeout=10)
Method description
Mouse move
Parameter descriptions
element<str>Target element
index<int> The index of the element to use if multiple are found.
parent_element<Element>The parent element.
timeout<int> Timeout
Example- rpa.app.ie.IETab.mouse_move-
# Notes:
# 1. This method operates on an IETab instance object. Before you use this method, you must use the element capturing feature to obtain the target element from the page.
# 2. This method automatically scrolls the page to make the target element visible.
# The following code sample shows how to use this method. After the code is run, the program moves the mouse cursor to the specified element.
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
page.mouse_move('webpage_bottom-ie')Drag
drag(element, x=0, y=0,speed_mode='uniform', index=1, parent_element=None, timeout=10)
Method Description
Drag the element to the specified position.
Parameter Descriptions
element<str>The target element.
x <int> The offset on the x-axis.
y <int> The y-axis offset.
speed_mode<str>The speed mode for dragging.
uniform: Drag at a constant speed.
fast-slow-pause: Drag starts fast, then slows down, and finally pauses to align. This simulates how a person drags an object.
index<int> If multiple elements are found, specify the index of the element.
parent_element<Element> The parent element.
timeout<int> The timeout period.
Example- rpa.app.ie.IETab.drag-
# Note: This method operates only on IETab instance objects. Before using this method, you must obtain the page elements by using the element capture feature.
# The following is a code sample:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
page.drag('login_button-ie',x=-500,y=100)get_element_by_name
get_element_by_name(element, index=1, parent_element=None, timeout=10)
Method description
Retrieve an object
Parameters
element<str>The UI element
index<int>If there are multiple, specify the index of the element.
parent_element<Element>The parent element.
timeout<int>Timeout period
Return Values
Returns the element object <Element>
Example- rpa.app.ie.IETab.get_element_by_name-
# Note: This method can be used only with IETab instance objects. Before you use this method, you need to use the element capturing feature to obtain the element from the page.
# The following provides a code example:
url = 'https://www.baidu.com/'
page = rpa.app.ie.create(url)
element = page.get_element_by_name('Baidu Search button-ie')
text = element.text()get_element_by_css
get_element_by_css(css, index=1, parent_element=None, timeout=10)
Method Description
Get elements by CSS selector
Parameter descriptions
css<str> CSS selector
index<int>Specify the element index if multiple elements are found.
parent_element<Element>The parent element.
timeout<int>Timeout period
Return Value Description
Returns the element object <Element>
Sample Call- rpa.app.ie.IETab.get_element_by_css-
# Notes:
# 1. This method can only operate on IETab instance objects.
# 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 sample:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
css_selector = "span.menu-title-text"
element = page.get_element_by_css(css_selector)
text = element.text()URL
url()
Method description
Obtain the URL
Return Value Description
Return URL<str>
Example - rpa.app.ie.IETab.url-
# Note: This method can only be used with an IETab instance object.
# The following is a code sample:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
get_url = page.url()Title
title()
Method Description
Obtain the title
Return values
Returns the title<string>
Example - rpa.app.ie.IETab.title-
# Note: This method can only be used with an IETab instance object.
# The following is a code sample:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
title= page.title()Reload
reload(wait=True, timeout=100)
Method Description
Refresh the page
Parameters
wait<bool> Specifies whether to wait for the loading to complete.
timeout<int> The timeout period. The default value is 100 s.
Sample Call- rpa.app.ie.IETab.reload-
# Note: This method can only operate on an IETab instance object.
# The following is a code example:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
page.reload()attr
attr(element, name, index=1, parent_element=None, timeout=10)
Method description
Obtain attributes
Parameter description
element<str>The control.
name<str> The attribute name.
index<int> If there are multiple, specify the index of the element.
parent_element<Element>The parent element.
timeout<int> Timeout period.
Return value description
Return attribute <str>
Sample Call- rpa.app.ie.IETab.attr-
# Note: This method can only be used with an IETab instance object.
# Example code call:
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
attribute = page.attr('login-button-ie','class')in_view
in_view(element, index=1, parent_element=None, timeout=10)
Method Description
Whether the element is in the visible area
Parameter description
element<str>element
index<int> Specifies the index of the element if multiple elements exist.
parent_element<Element>The parent element.
timeout<int>The timeout period.
Return value description
Returns whether the element is in the visible area <bool>
Sample - rpa.app.ie.IETab.in_view -
# Note: This method operates only on IETab instance objects. Before use, you must capture the page element by using the capture element feature.
# The following is a code sample. It produces the XX result (Provide a brief description of the sample code).
url = 'https://help.aliyun.com/document_detail/175379.html'
page = rpa.app.ie.create(url)
flag = page.in_view('Login button-ie')