Skip to content

Instantly share code, notes, and snippets.

@mpahuja
Created September 24, 2019 06:29
Show Gist options
  • Save mpahuja/aeb265d44160221893364162fd4e098f to your computer and use it in GitHub Desktop.
Save mpahuja/aeb265d44160221893364162fd4e098f to your computer and use it in GitHub Desktop.
Pages - TableView.swift
import XCTest
public final class TableViewPage: BasePage {
// Mark: - Page UI elements
private var entireTable: XCUIElement {
return app.tables.allElementsBoundByAccessibilityElement[0]
}
private var countTableRow: XCUIElementQuery {
return app.tables.cells
}
// Mark: Page UI element interation
public func isRandomTableDisplayed() -> Bool {
return self.entireTable.waitForExistence(timeout: 10.0)
}
public func countTableRows() -> Int {
return self.countTableRow.count
}
public func tapDesiredRow(desiredIndex: Int) {
return self.countTableRow.allElementsBoundByIndex[desiredIndex].tap()
}
public func getValueAtDesiredRow(desiredIndex: Int) -> String {
let currentValueAtIndex = self.countTableRow.allElementsBoundByIndex[desiredIndex].title
return currentValueAtIndex
}
public func isCorrectAlertDisplayed(rowTitle: String) -> Bool {
return app.alerts[rowTitle].isEnabled
}
public func tapOkOnAlert() -> Bool {
if app.alerts.buttons["OK"].exists {
app.alerts.buttons["OK"].tap()
}
return true
}
}
extension BaseTest {
public var tableViewPage: TableViewPage {
return getPage()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment