This extension adds a computed property isVisible
to XCUIElement
. It is useful in UI Testing
for checking if a specified element is visible on the screen.
Add the following line to the target UITests
in your Podfile
:
pod 'XCUIElement+IsVisible'
Add the following line to dependencies
in your Package.swift
file:
.package(url: "https://github.com/albinekcom/XCUIElement-IsVisible.git", from: "0.0.1")
Add XCUIElement+IsVisible.swift
file from Sources
directory into your project.
- Add
import
statement in your class which inherits fromXCTestCase
(not needed if you install it manually):
import XCUIElement_IsVisible
- Receive desired
XCUIElement
in your test method and use itsisVisible
computed property:
func testExample() {
let element = // (...)
XCTAssertTrue(element.isVisible)
}
Check out Example
project in Example
directory.