-
Notifications
You must be signed in to change notification settings - Fork 398
/
Copy pathPage.swift
57 lines (47 loc) · 1.61 KB
/
Page.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
// Page.swift
// MullvadVPNUITests
//
// Created by Niklas Berglund on 2024-01-10.
// Copyright © 2024 Mullvad VPN AB. All rights reserved.
//
import Foundation
import XCTest
class Page {
let app: XCUIApplication
/// Element in the page used to verify that the page is currently being shown, usually accessibilityIdentifier of the view controller's main view
var pageElement: XCUIElement?
@discardableResult init(_ app: XCUIApplication) {
self.app = app
}
func waitForPageToBeShown() {
if let pageElement {
XCTAssertTrue(
pageElement.waitForExistence(timeout: BaseUITestCase.defaultTimeout),
"Page is shown"
)
}
}
@discardableResult func enterText(_ text: String) -> Self {
app.typeText(text)
return self
}
@discardableResult func dismissKeyboard() -> Self {
self.enterText("\n")
return self
}
/// Fast swipe down action to dismiss a modal view. Will swipe on the middle of the screen.
@discardableResult func swipeDownToDismissModal() -> Self {
app.swipeDown(velocity: .fast)
return self
}
@discardableResult func tapKeyboardDoneButton() -> Self {
app.toolbars.buttons["Done"].tap()
return self
}
@discardableResult func tapWhereStatusBarShouldBeToScrollToTopMostPosition() -> Self {
// Tapping but not at center x coordinate because on iPad there's an ellipsis button in the center of the status bar
app.coordinate(withNormalizedOffset: CGVector(dx: 0.75, dy: 0)).tap()
return self
}
}