AI validation (FR) 
Perfecto Command
perfecto:ai:validation
Important: If you access and use any features provided in Beta mode, we would love to hear your feedback or functionality suggestions before the Beta feature becomes generally available and fully supported under a subscription license model. Feel free to contact Perfecto Support anytime!
Purpose
Use the perfecto:ai:validation
command in Appium tests while running tests on Perfecto devices.
To learn more about working with AI-powered validations, see the following resources:
Important: To enable AI commands in your cloud, see Manage AI consent .
Parameters
Name | Type | Possible Values | Description |
---|---|---|---|
Validation |
String |
|
The question to validate the device screen information. The result is always pass or fail. You can type a question of up to 2000 characters. To learn more, see Create AI-powered validations . |
Return Value
True or False
Test failure
A test doesn't fail if something is not correct. You can implement an additional assertion and fail the test manually if needed.
Exceptions
The following message appears when your cloud does not have the consent to use AI:
Failed to execute command ai:validation: Unexpected error occurred while processing command 'ai:validation'. Error message: AI commands are disabled. To use these commands, contact your administrator. Status: Forbidden
Examples
Copy
JavaScript
const result = await driver.executeScript("perfecto:ai:validation", {validation: "Is there a Save button?"});
if (result.toString().toLowerCase() === "true")
{
// Start the reporting step
reportiumClient.stepStart("Save expense");
// Wait for the Save button to become clickable
const saveExpenseButton = await driver.$("#layout_buttons");
await saveExpenseButton.waitForClickable({ timeout: 5000 });
await saveExpenseButton.click();
// End the reporting step
reportiumClient.stepEnd();
}
else
{
console.log("There is no Save button");
}
Copy
Java
Object result = driver.executeScript("perfecto:ai:validation", Map.of("validation", "Is there a Save button?"));
if ("true".equalsIgnoreCase(result.toString()))
{
reportiumClient.stepStart("Save expense");
AndroidElement save_expense = (AndroidElement) wait.until(ExpectedConditions.elementToBeClickable(
driver.findElement(By.id("layout_buttons"))));
save_expense.click();
reportiumClient.stepEnd();
}
else
{
System.out.println("There is no Save button");
}