Skip to content

Instantly share code, notes, and snippets.

@SunXiaoShan
Created January 8, 2019 05:28
Show Gist options
  • Save SunXiaoShan/e5dc5ede2c82d1dab08402c10ab04524 to your computer and use it in GitHub Desktop.
Save SunXiaoShan/e5dc5ede2c82d1dab08402c10ab04524 to your computer and use it in GitHub Desktop.
class LibraryPage: Page {
lazy var libraryTab = app.tabBars.buttons["Library"]
var selectIndex: Int = 0
func switchToLibrary() -> Self {
libraryTab.tap()
snapshot("switch to library page")
return self
}
func getTableViewCell(_ index: Int) -> XCUIElement {
let table = app.tables.element(boundBy: 0)
let cell = table.cells.element(boundBy: index)
guard waitForElementToAppear(cell) else {
XCTFail()
return cell
}
return cell
}
func tapTableViewCell(_ index: Int) -> Self {
getTableViewCell(index).tap()
snapshot("tab cell:\(index)")
return self
}
@discardableResult func actionPlayButton(_ index: Int) -> Self {
let element = getTableViewCell(index).buttons["Button"]
guard waitForElementToAppear(element) else {
XCTFail()
return self
}
element.tap()
snapshot("switch to play video index:\(index)")
return self
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment