Jetpack Compose - basic test
import io.mobileboost.gptdriver_ktl.GptDriver
import androidx.compose.ui.test.junit4.createComposeRule
import org.junit.Rule
import org.junit.Test
class LoginTest {
@get:Rule
val composeTestRule = createComposeRule()
@Test
fun testLoginFlow() {
val gptDriver = GptDriver(
apiKey = "<YOUR_API_KEY>",
deviceName = "Emulator",
platformVersion = "N/A",
cachingMode = "INTERACTION_REGION",
testId = "testLoginFlow",
composeTestRule = composeTestRule
)
gptDriver.execute("Tap on the email field and type test@example.com")
gptDriver.execute("Tap on the password field and type SecurePass123")
gptDriver.execute("Tap the Sign In button")
gptDriver.assert("The home screen is displayed with a welcome message")
}
}
With additional context
val gptDriver = GptDriver(
apiKey = "<YOUR_API_KEY>",
deviceName = "Pixel 8",
platformVersion = "14.0",
additionalUserContext = "When asked about notifications, tap Allow. Dismiss any marketing banners.",
cachingMode = "INTERACTION_REGION",
testId = "testOnboarding",
composeTestRule = composeTestRule
)
gptDriver.execute("Complete the onboarding by tapping Next on each screen")
gptDriver.execute("Tap Get Started")
gptDriver.assert("The main dashboard is visible")
Data extraction
val gptDriver = GptDriver(
apiKey = "<YOUR_API_KEY>",
deviceName = "Emulator",
platformVersion = "N/A",
composeTestRule = composeTestRule
)
gptDriver.execute("Navigate to the profile screen")
val data = gptDriver.extract("username", "email", "plan type")

