How to assert if a view is off screen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import XCTest | |
| class UITests: XCTestCase { | |
| let app = XCUIApplication() | |
| override func setUp() { | |
| super.setUp() | |
| continueAfterFailure = false | |
| app.launch() | |
| } | |
| func testElementIsOnScreen() { | |
| let windowFrame = app.windows.elementBoundByIndex(0).frame | |
| let onScreenElementFrame = app.buttons["On"].frame | |
| let offScreenElementFrame = app.buttons["Off"].frame | |
| XCTAssert(CGRectContainsRect(windowFrame, onScreenElementFrame)) | |
| XCTAssertFalse(CGRectContainsRect(windowFrame, offScreenElementFrame)) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment