AI validation (FR) 
Perfecto Command
Perfecto:ai-validate
Purpose
Use Perfecto's ai-validation command in Appium tests while running tests on Perfecto devices.
To learn more about working with AI-powered validations, check out the following resources:
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
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");
}
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");
}