Skip to content

Commit

Permalink
Add Element.exists
Browse files Browse the repository at this point in the history
  • Loading branch information
bootstraponline committed May 3, 2019
1 parent e2f35e6 commit eb909a4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions SwiftUITest/SwiftUITest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public struct Timeout {
}

public protocol Element {
var exists: Bool { get }
var isVisible: Bool { get }
var isVisibleNow: Bool { get }
var value: String { get }
Expand Down
5 changes: 5 additions & 0 deletions SwiftUITest/XCUIElementWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ struct XCUIElementWrapper: Element {
self.testCase = testCase
}

var exists: Bool {
waitToExist(Timeout())
return element.exists
}

var label: String {
waitToExist(Timeout())
return element.label
Expand Down
6 changes: 6 additions & 0 deletions Tests/XCUIElementWrapper_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import SwiftUITest

class XCUIElementWrapper_Tests: SwiftUITestCase {

func test_exists() {
let label = "Accessibility Views"
let ele = driver.find(label: label)
XCTAssertTrue(ele.exists == true)
}

func test_label() {
let label = "Accessibility Views"
let ele = driver.find(label: label)
Expand Down

0 comments on commit eb909a4

Please sign in to comment.