All of the above assertion functions have optional message as last parameter that can be used to configure what is displayed if assertion fails. For example: element.assertExists("My element should be visible").
For details see documentation.
Example
Here is a short example from one of my apps that makes use of this library. In the test I am checking that it is possible to navigate to “Premium features” screen, verify that most important data is visible and check that it is possible to leave that screen.
Note that some of the buttons are identified by enum case instead of raw string. You can see type safe identifiers tip below to see how this is implemented.
XCAppTest
Utilities for easier interaction with XCUITest methods.
What’s included
XCUIElement
extensions:assertExists()
assertExists(waitForAppToIdle: true)
assertNotExists()
assertExists(false)
assertIsHittable()
assertIsNotHittable()
assertIsHittable(false)
assertIsEnabled()
assertIsDisabled()
assertIsEnabled(false)
assertIsInteractive()
(exists, isHittable, isEnabled)assertHasLabel("label")
assertContainsText("label")
assertHasValue("equatable value")
assertHasPlaceholder("placeholder")
assertIsSelected()
assertIsNotSelected()
assertIsSelected(false)
tapWhenReady()
waitForInteractivity()
slowTypeText("text")
tap(withNormalizedOffset: .center)
XCUIApplication
extensions:XCUIApplication.safari
assertIsInForeground()
assertIsNotInForeground()
assertIsInForeground(false)
moveToBackground()
XCUIElementQuery
extensions:assertHasCount(2)
assertNotExists()
CGVector
extensions:topLeft
,top
,topRight
left
,center
,right
bottomLeft
,bottom
,bottomRight
All of the above assertion functions have optional message as last parameter that can be used to configure what is displayed if assertion fails. For example:
element.assertExists("My element should be visible")
. For details see documentation.Example
Here is a short example from one of my apps that makes use of this library. In the test I am checking that it is possible to navigate to “Premium features” screen, verify that most important data is visible and check that it is possible to leave that screen.
Note that some of the buttons are identified by enum case instead of raw string. You can see type safe identifiers tip below to see how this is implemented.
Installation
Swift Package Manager
Package.swift
file:XCAppTest
as a dependency for your tests target:import XCAppTest
in your tests source code.Xcode
Add https://github.com/Tunous/XCAppTest.git, to the list of Swift packages for your project in Xcode and include it as a dependency on your tests target.