Basic Operations API

The basic operation API for automating Windows application objects is obtained by introducing the "WinAuto" class object exported from the "leanpro.win" package.

JavaScript
const { WinAuto } = require('leanpro.win');

WinAuto

The WinAuto object is used to directly generate Test Object through Descriptive Mode,without loading the object model.

This class has the following methods:

JavaScript
class WinAuto {
    static fromPoint(x: number, y: number): Promise<IWinControl>;
    static get(obj: IWinControl): IWinTypeControl;
    static highlight(rect: Rect, duration: number);
    static loadModel(modelPath: string): IModel;
}

  • loadModel

loadModel load object model from a model file, and return the model object. The following is an example:

JavaScript
const { WinAuto } = require("leanpro.win");
var model = WinAuto.loadModel(__dirname + "/simle_styles.tmodel");

async function run() {
    await model.getButton("Default").click();
}

run();

  • bindToProcess

bindToProcess is used to bind the model to a process of the automation application. In some situation, there are multiple identical application instances during runtime, if this method is called to bind to one of the process, the rest calls on this model object will only manipulate this specific application.

results matching ""

    No results matching ""