You can utilize our our Swift SDK with or without appium. Appium has the advantage that our SDK can interact with the full device, whereas with the XCUITest method we can only interact with the app itself.
Import the GPT Driver pacakge
import gptd_swift
Initialize GPT Driver in the setUp function of an XCTestCase file, and pass the XCUIApplication instance.
DemoUITests.swift
import XCTest
import gptd_swift
@MainActor
final class DemoUITests: XCTestCase {
var app: XCUIApplication!
var gptDriver: GptDriver!
override func setUpWithError() throws {
continueAfterFailure = false
app = XCUIApplication()
app.launch()
// Init gpt driver by passing the XCUIApplication
gptDriver = GptDriver(
apiKey: "TEST_API_KEY",
nativeApp: app
)
}
override func tearDownWithError() throws {
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")
}
}
Import the GPT Driver pacakge
import gptd_swift
Initialize GPT Driver in the setUp function of an XCTestCase file, by providing the appium server URL
DemoUITests.swift
import XCTest
import gptd_swift
@MainActor
final class DemoUITests: XCTestCase {
var app: XCUIApplication!
var gptDriver: GptDriver!
override func setUpWithError() throws {
continueAfterFailure = false
app = XCUIApplication()
app.launch()
// Init gpt driver by passing the appium server URL
gptDriver = GptDriver(
apiKey: "TEST_API_KEY",
appiumServerUrl: URL(string: "http://localhost:4723")!
)
}
override func tearDownWithError() throws {
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")
}
}