Basic test with self healing
import io.mobileboost.gptdriver.*;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.options.UiAutomator2Options;
public class LoginTest {
public static void main(String[] args) throws Exception {
UiAutomator2Options options = new UiAutomator2Options();
options.setCapability("gptdriver:apiKey", "YOUR_API_KEY");
// GptDriverAndroid wraps AndroidDriver with self-healing
AndroidDriver driver = new GptDriverAndroid(
new java.net.URL("http://127.0.0.1:4723"),
options
);
// These findElement calls are self-healing -
// if an element ID changes, the SDK finds the right one
driver.findElement(By.id("login-email")).sendKeys("test@example.com");
driver.findElement(By.id("login-password")).sendKeys("password123");
driver.findElement(By.id("login-button")).click();
// Use AI for complex assertions
driver.aiAssert("The home screen is displayed with a welcome message");
driver.quit();
}
}
AI commands for non-native elements
GptDriverAndroid driver = new GptDriverAndroid(
new java.net.URL("http://127.0.0.1:4723"),
options,
"When asked about Location Permissions, grant it."
);
// AI handles web views and third-party components
driver.aiExecute("Tap the 'Accept cookies' button in the web view");
driver.aiExecute("Scroll down and tap on 'View pricing'");
// Extract data from the screen
Map<String, String> data = driver.aiExtract("plan name", "monthly price");
// Strict check without self healing
GptDriverAndroid gptDriver = (GptDriverAndroid) driver;
WebElement el = gptDriver.findElement(By.id("success-banner"), false);
Assert.assertTrue(el.isDisplayed());

