CukeTest APIs

CukeTest provides a library for manipulating and obtaining various properties of itself, and the name of the library is cuketest.

This library is only used to automate CukeTest. If you need to automate other applications, please use the automation API package prefixed with "leanpro."

How to introduce

Import the cuketest library using the code below. Or directly drag and drop related automation operations from "Toolbox" -> "Cucumber" to generate.

JavaScript
const {CukeTest} = require("cuketest");

Introduction to the cuketest library

The main object of the cuketest library is CukeTest, and the type definition of this object is as follows:

JavaScript
    export class CukeTest {
        static minimize(): void;
        static maximize(): void;
        static restore(): void;
        static connect(options: ClientConnectOptions, caps?: DesiredCapabilities | ICapabilities): Promise<IAuto>;
        static info(): Promise<RunInfo>;
    }
For example, the following code can be used to minimize the entire CukeTest window during a test run, then restore the CukeTest window size after the test is complete:
JavaScript
const {CukeTest} = require("cuketest");
CukeTest.minimize();

//...perform a test operation...//

CukeTest.restore();

automation API

The following are instructions for using the API:

minimize()

Minimize the CukeTest window.

  • Return value: does not return any value.

maximize()

Maximize the CukeTest window.

  • Return value: does not return any value.

restore()

Restore the CukeTest window to normal size. Equivalent to clicking the "Restore" option that appears when you right-click a window.

  • Return value: does not return any value.

connect(options: ClientConnectOptions, caps?: DesiredCapabilities)

Connect to the execution end (Worker) of remote automation. Returns the remote automation auto object. For more information, see Remote Automation

info():Promise<RunInfo>

Get runtime information, which will be returned as an object.

Runtime information object RunInfo

JavaScript
interface RunInfo {
    readonly argv: string[];
    readonly profile: Profile;
}

  • argv: string[] string array type, an array composed of command line parameters passed to CukeTest, such as ["--run", "--format", "html"].
  • profile: Profile object, which represents the object of the current run configuration.

Run configuration object Profile

The object used to represent the running configuration, the type is defined as follows:

JavaScript
interface Profile {
    name: string,
    format: string[],
    out: string,
    screenId: string,
    screenName: string,
    runItems: string[],
    custom: string
}

  • name: string type, the name of the running configuration.
  • format: string[] type, report output type, support option reference run configuration: report format
  • out: string type, the report output directory, if not specified, it will be empty, and the report will be generated in the reports folder of the project.
  • screenId: string type, the recorded screen number, used to record the running video, if it is empty, it will not record.
  • screenName: string type, the name of the recorded screen, which has the same function as screenId, used to record the running video, if it is empty, it will not be recorded.
  • runItems: string[] type, run sequence.
  • custom: string type, custom parameters.

For example, if you want to get the name of the current running configuration during script running, you can write as follows:

JavaScript
const { CukeTest } = require("cuketest");
let info = await CukeTest.info();
console.log(`The name of the current running configuration is: ${info.profile.name}`)

results matching ""

    No results matching ""