Initialize GPT Driver in the setUp function of an XCTestCase file
XCTestCase File
import XCTest
import gptd_swift
@MainActor
final class DemoUITests: XCTestCase {
var app: XCUIApplication!
var gptDriver: GptDriver!
override func setUpWithError() throws {
// Stop immediately when a failure occurs.
continueAfterFailure = false
// init gpt driver
gptDriver = GptDriver(
apiKey: "TEST_API_KEY",
appiumServerUrl: URL(string: "http://localhost:4723")!
)
// Initialize the app
app = XCUIApplication()
app.launch()
}
override func tearDownWithError() throws {
// Cleanup code if needed.
app = nil
}
func testNavigationToSecondScreen() async throws {
try await gptDriver.execute("Tap on the Go to Second Screen button")
try await gptDriver.execute("Check if you can see a screen with a second screen headline")
}
}