2016-08-23 66 views
1

我目前正在做我的應用程序的ui測試,並堅持單擊我的應用程序的登錄按鈕。我無法找到我給了標識符註冊按鈕的元素(元素是第三個索引,這不是問題)。ui測試xcode,如何點擊表格查看單元格按鈕與cellquery

let cellQuery = self.app.tables.cells.element(boundBy: 3) 

let signInButton = cellQuery.buttons["signup button"] 
if signInButton.exists { 
    signInButton.tap() 
} 
+0

指向屏幕的鏈接hot和'signInButton.debugDescription'輸出的轉儲對上下文有幫助。 – Oletha

回答

4

如果按鈕出現在第三小區,那麼它應該是:

let cellQuery = self.app.tables.cells.element(boundBy: 2) 
cellQuery.buttons["signup button"].tap() 

如果按鈕處於第三在細胞然後將細胞添加輔助功能,然後:

app.cells["AccessibilityIdentifier"].buttons.element(boundBy: 2).tap() 
2

可以這樣做:

XCUIApplication().tables.cells.element(boundBy: 2).buttons["signup button"].tap()