Control

更新时间:
复制 MD 格式

add

add(name, value, mode='json')

Description

Adds a control.

Parameters

name <str> The name of the control.

value <dict> The meta object of the control.

mode <str> The data format.

Optional:

  • json: The value is in JSON format.

  • xml: The value is in XML format.

Example call: rpa.ui.ctrl.add-

# Note:
# Control information captured using the control capture feature is recorded in the .ctrl.json file of the project.
# This method does not add control information to the JSON file. It only temporarily adds a control during code execution.
# The following code provides an example:
raw = r'<wnd x:tag="tab" title="Baidu it, and you will know" /><chrome x:tag="input" id="kw" />'
rpa.ui.ctrl.add("add_control_test",raw,mode="xml")

get

get(name, mode='json')

Description

Retrieves the meta object of a control.

Parameters

name <str> The name of the control.

mode <str> The data format of the return value.

Optional:

  • json: Returns the value in JSON format.

  • xml: Returns the value in XML format.

Return value

The meta object of the control, returned as a <list>.

Sample call: rpa.ui.ctrl.get

# Note:
# Before using this method, capture the corresponding control using the control capture feature.
# If you set the mode parameter to xml, a string is returned. For information about the string format, see the Edit Control window.
# The following code provides an example:
beta = rpa.ui.ctrl.get("baidu_search",mode="xml")

remove

remove(name)

Description

Deletes a control.

Parameters

name <str> The name of the control.

Sample Call: rpa.ui.ctrl.remove

# Note:
# Control information captured using the control capture feature is recorded in the .ctrl.json file of the project.
# This method does not delete control information from the JSON file. It only disables the specified control during code execution.
# The following code provides an example:
rpa.ui.ctrl.remove("baidu_search")

update

update(name, value, mode='json')

Description

Updates a control.

Metric description

name <str> The name of the control.

value <dict> The meta object of the control.

mode <str> The data format.

Optional:

  • json: The value is in JSON format.

  • xml: The value is in XML format.

Example call: rpa.ui.ctrl.update

# Note:
# Control information captured using the control capture feature is recorded in the .ctrl.json file of the project.
# This method does not modify the control information in the JSON file. It only updates the control information during code execution.
# The following code provides an example. In this example, a control is first captured in the Chrome browser. Then, this method is used to change the browser information of the control to IE.
page1 = rpa.app.chrome.create('www.baidu.com')
page1.input_text('baidu_search', 'Alibaba-chrome')
​
raw_ie = r'<wnd x:tag="tab" title="Baidu it, and you will know" /><ie x:tag="input" id="kw" />'
rpa.ui.ctrl.update("baidu_search",raw_ie,mode="xml")
page2 = rpa.app.ie.create('www.baidu.com')
page2.input_text('baidu_search', 'Alibaba')