Reference
Basics
GPT Driver Classes
To use Self Healing and AI Commands the SDK provides 3 classes:
GptDriverAndroid
(extendsAndroidDriver
)GptDriverIOS
(extendsIOSDriver
)GptDriverAppium
(extendsAppiumDriver
)
Additional User Context
You can pass additional context through the GPT driver constructor to enhance its actions by providing specific application or test details. This additional information is leveraged during all self-healing and AI command calls, enabling you to control generic behavior of the driver.
// passing additionalUserContext about granting location permission requests
GptDriverAndroid driver = new GptDriverAndroid(
new java.net.URL("http://127.0.0.1:4723"),
options,
"When asked about Location Permissions, grant it."
)
Self Healing
By default the GPT Driver attempts to self heal failing findElement(s) calls. It catches the NoSuchElement exceptions thrown and tries to complete this step by waiting if the element will appear within a few seconds, dismissing unexpected popups, exploring the screen by scrolling, inspecting available elements for same intent.
This allows the GPT Driver to self heal common flakiness reasons such as:
dynamic loading times
changed element ids
changed UI layout
changed text
unexpected popups
All catched exceptions and details about which locator has been used to heal the tests can then be found on a dashboard: https://app.mobileboost.io/gpt-driver/sessions
To disable self healing for a specific command in your code, you can set the selfHealing
parameter on the findElement(s) methods to false.
To disable self healing in general you can set the enableSelfHealing
to false for the GPT Driver constructor.
AI Commands
aiExecute
Will execute a given natural language instruction. Please refer to our Prompt Guide for best practices.
// simple instructions
driver.aiExecute("tap on the login button")
// more abstract instructions
driver.aiExecute("Navigate to the settings screen")
// complex instructions
driver.aiExecute("Check that you see a list of hotel room options, if so tap on the cheapest room option")
aiAssert
Verify something without taking any action. The function will pass or throw an error
driver.aiAssert("The total price is " + price);
aiAssertBulk
Check multiple conditions are met in one go. The function will throw an error if any of the assertions is not true.
driver.aiAssertBulk(Arrays.asList(
"The total price is $" + price,
"The VAT is calculated correctly",
"The delivery date is shown in the format dd.mm.YYYY"
));
aiCheckBulk
Check multiple conditions are met in one go. The function will return a object with true and false values for each conditions.
Map<String, Boolean> assertResults = driver.aiCheckBulk(Arrays.asList(
"The total price is $" + price,
"The VAT is calculated correctly",
"The delivery date is shown in the format dd.mm.YYYY"
));
aiExtract
Extract information from current screen. Returns an object with the extracted values.
// example to extract flight informationn from a screen
Map<String, Object> flightInformation = driver.aiExtract(Arrays.asList(
"departureAirportCode",
"destinationAirportCode",
"departureTime",
"destinationTime",
"travelTime"
));
// Using the extracted information in assertions
driver.aiAssertBulk(Arrays.asList(
"departure airport is " + flightInformation.get("departureAirportCode"),
"destination airport is " + flightInformation.get("destinationAirportCode")
));
Last updated