我试图在UITest中断言双击主页图标会将我的表格视图滚动回到顶部。
我认为要执行此操作的模式是:加载视图,滚动,断言它似乎不可见,点击主页并断言现在可以。
我有这样的东西
let username = "...."
let password = "...."
app.launch()
let loginPage = app.otherElements["login page"]
loginPage.waitForExistence()
let usernameInputField = app/*@START_MENU_TOKEN@*/.webViews.textFields["Email address"]/*[[".otherElements[\"bfx_login\"].webViews",".otherElements[\"Log in to OneHub | Recognition\"].textFields[\"Email address\"]",".textFields[\"Email address\"]",".webViews"],[[[-1,3,1],[-1,0,1]],[[-1,2],[-1,1]]],[0,0]]@END_MENU_TOKEN@*/
usernameInputField.tap()
usernameInputField.typeText(username)
let passwordInputField = app/*@START_MENU_TOKEN@*/.webViews.secureTextFields["Password"]/*[[".otherElements[\"bfx_login\"].webViews",".otherElements[\"Log in to OneHub | Recognition\"].secureTextFields[\"Password\"]",".secureTextFields[\"Password\"]",".webViews"],[[[-1,3,1],[-1,0,1]],[[-1,2],[-1,1]]],[0,0]]@END_MENU_TOKEN@*/
passwordInputField.tap()
passwordInputField.typeText(password)
loginPage.buttons["Log In"].tap()
let tabBarController = app.tabBars["home_tabBarController"]
tabBarController.waitForExistence()
let activityFeed = app.tables["Activity Feed"]
activityFeed.waitForExistence()
app.swipeUp()
XCTAssertFalse(activityFeed.cells.element(boundBy: 0).isHittable)
let homeButton = tabBarController.children(matching: .button).element(boundBy: 0)
homeButton.waitForExistence()
homeButton.doubleTap()
XCTAssertTrue(activityFeed.cells.element(boundBy: 0).isHittable)
除了能够对单元格进行断言之外,所有其他工作都可以进行。我不相信
XCTAssertFalse(activityFeed.cells.element(boundBy: 0).isHittable)
和
XCTAssertTrue(activityFeed.cells.element(boundBy: 0).isHittable)
按照我的预期工作。
如何断言表格视图中的单元格可见?
答案 0 :(得分:0)
要检查是否可见,you want to use isHittable in conjunction with exists。另请参见here。 像这样:
element.exists && element.isHittable
您说过isHittable对您不起作用,您能解释一下它不起作用吗?