E2ETestScope

class E2ETestScope(driver: TestDriver, config: E2ETestConfig)

Primary execution scope for a Parikshan end-to-end test scenario.

E2ETestScope provides an intent-based DSL for driving Compose Multiplatform user interfaces across Android, iOS, Desktop, and Wasm. Inside this scope, you perform actions (click, input, scroll), assert UI state (assertVisible, assertText), and handle platform-conditional logic.

All methods automatically handle element polling, visibility verification, and virtual cursor updates.

See also

Constructors

Link copied to clipboard
constructor(driver: TestDriver, config: E2ETestConfig)

Properties

Link copied to clipboard

The target execution platform string (e.g. "android", "ios", "desktop", "wasm").

Functions

Link copied to clipboard
fun artifactPath(relativePath: String): String

Resolves a relative path to an absolute path inside the project's build and report output directory.

Link copied to clipboard
suspend fun assertContains(selector: Selector, substring: String)

Asserts that the UI element matching selector contains the substring.

suspend fun assertContains(tag: String, substring: String)

Asserts that the UI element matching string tag contains the substring.

Link copied to clipboard
suspend fun assertFailure(messageContains: String, block: suspend E2ETestScope.() -> Unit)

Asserts that executing block fails with an AssertionError containing messageContains.

Link copied to clipboard
suspend fun assertNotVisible(tag: String, message: String? = null)

Asserts that a UI element matching string tag is NOT visible on screen.

suspend fun assertNotVisible(selector: Selector, message: String? = null, timeoutMs: Long = config.defaultWaitTimeoutMs)

Asserts that a UI element matching selector is NOT visible on screen.

Link copied to clipboard
suspend fun assertText(selector: Selector, expected: String)

Asserts that the UI element matching selector displays exact text expected.

suspend fun assertText(tag: String, expected: String)

Asserts that the UI element matching string tag displays exact text expected.

Link copied to clipboard
suspend fun assertValue(selector: Selector, expected: String)

Asserts that an input element matching selector has text value expected.

suspend fun assertValue(tag: String, expected: String)

Asserts that an input element matching string tag has text value expected.

Link copied to clipboard
suspend fun assertVisible(selector: Selector)

Asserts that a UI element matching selector is present and visible on screen.

suspend fun assertVisible(tag: String)

Asserts that a UI element matching string tag is present and visible on screen.

Link copied to clipboard
suspend fun click(selector: Selector)

Executes a physical tap or click on the UI element matching the specified selector.

suspend fun click(tag: String)

Executes a physical tap or click on the UI element matching the provided string tag or text.

Link copied to clipboard
suspend fun drag(selector: Selector, offsetX: Double, offsetY: Double, durationMs: Long = 300)

Drags the UI element matching selector by moving it by (offsetX, offsetY) pixels.

suspend fun drag(tag: String, offsetX: Double, offsetY: Double, durationMs: Long = 300)

Drags the UI element matching string tag by moving it by (offsetX, offsetY) pixels.

suspend fun drag(fromX: Double, fromY: Double, toX: Double, toY: Double, durationMs: Long = 300)

Performs a physical touch or mouse drag gesture from (fromX, fromY) to (toX, toY) over durationMs.

Link copied to clipboard
suspend fun executeParallel(block: suspend E2ETestScope.() -> Unit)

Executes the provided test block concurrently across each active target driver in parallel.

Link copied to clipboard
suspend fun getTree(): List<NodeSnapshot>

Fetches the entire current UI hierarchy as a list of NodeSnapshots.

Link copied to clipboard
suspend fun hasVisibleNode(selector: Selector): Boolean

Checks whether a visible node matching the provided selector exists in the current UI tree.

suspend fun hasVisibleNode(selector: String): Boolean

Checks whether a visible node matching the provided selector string exists in the current UI tree.

Link copied to clipboard
suspend fun input(selector: Selector, text: String)

Clears any existing text and inputs text into the UI element matching the specified selector.

suspend fun input(tag: String, text: String)

Clears any existing text and inputs text into the UI element matching the string tag.

Link copied to clipboard

Returns true if the current test execution target is an Android device or emulator.

Link copied to clipboard

Returns true if the current test execution target is JVM Desktop.

Link copied to clipboard

Returns true if the current test execution target is an iOS simulator or device.

Link copied to clipboard

Returns true if the current test execution target is Web (WasmJs).

Link copied to clipboard
suspend fun onTarget(target: Target, block: suspend E2ETestScope.() -> Unit)

Executes the provided test block exclusively on the specified target platform.

Link copied to clipboard
suspend fun pressBack()

Triggers a system back navigation press.

Link copied to clipboard
suspend fun pressHome()

Triggers a system home button press to send the application to the background.

Link copied to clipboard
suspend fun relaunchApp()

Force-terminates and relaunches the application process under test while maintaining the active test connection session.

Link copied to clipboard
suspend fun resetApp()

Resets application state and clears test session caches.

Link copied to clipboard
suspend fun resolveNode(selector: Selector, requireVisible: Boolean = true): NodeSnapshot

Resolves and returns a NodeSnapshot for the element matching the provided selector.

suspend fun resolveNode(selector: String, requireVisible: Boolean = true): NodeSnapshot

Resolves and returns a NodeSnapshot for the element matching the provided selector string.

Link copied to clipboard
suspend fun resolveVisibleNode(selector: Selector): NodeSnapshot

Resolves and returns a visible NodeSnapshot matching the provided selector.

suspend fun resolveVisibleNode(selector: String): NodeSnapshot

Resolves and returns a visible NodeSnapshot matching the provided selector string.

Link copied to clipboard
suspend fun <T> retry(maxAttempts: Int = 3, delayMs: Long = 500, block: suspend E2ETestScope.() -> T): T

Retries executing block up to maxAttempts times with a delayMs pause between attempts.

Link copied to clipboard
suspend fun screenshot(path: String)

Captures a screenshot of the current application screen and saves it as a PNG to path.

Link copied to clipboard

Helper that resolves a logical name into a standard screenshot file path inside the build directory.

Link copied to clipboard
suspend fun scroll(selector: Selector, direction: ScrollDirection)

Performs a single scroll gesture on the container element matching selector in the specified direction.

suspend fun scroll(tag: String, direction: ScrollDirection)

Performs a single scroll gesture on the container element matching string tag in the specified direction.

Link copied to clipboard
suspend fun scrollUntilVisible(containerSelector: Selector, targetSelector: Selector, direction: ScrollDirection = ScrollDirection.Down, maxScrolls: Int = 30, stabilizationDelayMs: Long = 300)

Repeatedly scrolls the container matching containerSelector in direction until targetSelector becomes visible.

suspend fun scrollUntilVisible(containerTag: String, targetTag: String, direction: ScrollDirection = ScrollDirection.Down, maxScrolls: Int = 30, stabilizationDelayMs: Long = 300)

Repeatedly scrolls the container matching string containerTag in direction until targetTag becomes visible.

Link copied to clipboard
suspend fun takeScreenshot(hostPath: String)

Captures a screenshot of the current application screen and saves it as a PNG to hostPath.

Link copied to clipboard
suspend fun waitFor(selector: Selector, timeoutMs: Long = config.defaultWaitTimeoutMs)

Blocks execution until an element matching selector becomes visible.

suspend fun waitFor(tag: String, timeoutMs: Long = config.defaultWaitTimeoutMs)

Blocks execution until an element matching string tag becomes visible.