Object Operation APIs
ATK object operation APIs provide two types of methods: operations and properties. Operation methods are used to perform specific actions on controls, while property methods are used to get runtime properties of controls.
When using JavaScript APIs, since control access is asynchronous, property getter methods also appear in method form. This means you need to add parentheses
()when calling properties, and the return value is aPromiseobject. If used in anasyncfunction, you can get the actual value throughawait.
CukeTest provides rich APIs for controls in Linux desktop applications, making it easy for users to perform various operations and get properties of controls. These APIs cover common control operations such as clicking, entering text, getting values, etc., and also allow users to get various properties of controls, such as text, state, position, etc.
With these APIs, you can easily write automation scripts to ensure that all functional modules of Linux desktop applications work properly.
Common Methods
When using ATK object operation APIs, the following are some common operation and property methods:
- Operation Methods: These methods are used to perform actual actions on controls, such as clicking buttons, selecting list items, scrolling to a position, etc.
- Property Methods: These methods are used to get runtime properties of controls, such as getting the text content of a control, checking if a control is visible, getting the position of a control, etc.
Sample Code
The following is a simple example showing how to use ATK object operation APIs to get properties and perform operations:
// Assume we have a button control
let button = model.getButton("Button");
// Click the button
await button.click();
// Get the button's text property
let buttonName = await button.name();
console.log(`Button text: ${buttonText}`);# Assume we have a button control
button = model.getButton("Button")
# Click the button
button.click()
# Get the button's text property
button_name = button.name()
print(f"Button text: {button_name}")More API Documentation
More help on control operations and properties can be found in Common Control Methods, or viewed in the Model Manager. You can also hold down the Ctrl key and click on the leanpro.atk reference at the top of the script generated by dragging the model file to jump to the type definition file for more information.
- Common Control Methods: General operation and property APIs applicable to all ATK controls.
- List: APIs for operating list controls in ATK applications.
- Table: APIs for operating table controls in ATK applications.
- Tree: APIs for operating tree controls in ATK applications.