Add flexCorrect to capabilities

Learn how to add flexCorrect to your capabilities so your automation script will automatically select the right element—​even across different devices. Using flexCorrect will decrease the amount of Element not found errors you may get during testing.

Locate config file

First, open your test suite and locate your config file. The exact name and location may vary, but you’ll find it in a similar location:

Example
root
└── src
    └── test
        └── Config # Java TestNG
        └── Config.java # Java JUnit
        └── config.js # NodeJS Mocha

Add capability

In the config file, locate DesiredCapabilities, and add the following lines:

Capability Value

kobiton:flexCorrect

true

kobiton:baselineSessionId

Select a baseline session to use by assigning its session ID.

Example
public static DesiredCapabilities getIPhone11ProIOS146DesiredCapabilities() {
        DesiredCapabilities capabilities = new DesiredCapabilities();

        // Add these capabilities:

        capabilities.setCapability("kobiton:flexCorrect", true);  // Enable flexCorrect by setting capability to true.
        capabilities.setCapability("kobiton:baselineSessionId", 0000011); //  Select a baseline session by assigning its session ID.

    return capabilities;
}

When you’re finished, save your changes. Now flexCorrect will automatically select the correct elements, even when you run your script on different devices.

After a session, you can check how many elements were corrected.