Caching

To optimize execution time, you can use our caching mechanism. This way, AI is only required when changes are made to the test definition or the app, reducing unnecessary consumption for repetitive executions.

The SDK supports 3 caching modes:

  • NONE - No caching will be used

  • FULL_SCREEN - We only take an action from cache if the full screen matches previous successful executions

  • INTERACTION_REGION - We take an action from cache if the interaction region from a previous successful execution matches (e.g. the area of where we tapped on an element).

You can set those caching modes on a global level in the GPT Driver constructor, and/or overwrite the caching mode per step.

Setting caching mode in the GPT Driver constructor:

final class XcuiDemoUITests: XCTestCase {

    var app: XCUIApplication!
    var gptDriver: GptDriver!

    override func setUpWithError() throws {        
        // Initialize the app
        app = XCUIApplication()
        app.launch()
        
        // init gpt driver
        gptDriver = GptDriver(
            apiKey: "<YOUR_API_KEY>",
            nativeApp: app,
            cachingMode: CachingMode.interactionRegion,
            testId: self.name
        )
    }

    ...

Overwriting caching mode per step to disable or enable it for specific steps

try await gptDriver.execute(
    "Navigate to the Settings screen", 
    cachingMode: CachingMode.none
)   

Last updated