2015-10-16 70 views
2

我目前正在探索XCode中的新UITest庫,並且我想測試在單擊TextView內部時彈出的鍵盤是否具有正確的類型(在此它應該是.PhonePad)。UITest在XCode 7:如何測試鍵盤佈局(keyboardType)

我不認爲這是默認的XCUIElementXCUIElementAttributes(這仍然是一個有點模糊我的關於其實際意義)是可行的,而且我真的不明白我怎麼樣,什麼應該爲了延長能夠測試這個。

任何幫助將不勝感激! :)

朱利安

回答

0

下面我使用的測試手機號碼和密碼驗證校驗碼。

let app = XCUIApplication() 
let tablesQuery = app.tables 
tablesQuery.cells.containingType(.StaticText, identifier:"Login Using").buttons["Icon mail"].tap() 
tablesQuery.textFields["Phone Number"].tap() 
tablesQuery.cells.containingType(.SecureTextField, identifier:"Password").childrenMatchingType(.TextField).element.typeText("ooo") 
tablesQuery.staticTexts["Login Using"].swipeUp() 
tablesQuery.secureTextFields["Password"].tap() 
tablesQuery.cells.containingType(.Button, identifier:"Login").childrenMatchingType(.SecureTextField).element.typeText("eeee") 
tablesQuery.buttons["Login"].tap() 
app.alerts["Error"].collectionViews.buttons["OK"].pressForDuration(1.1); 

我希望這會對你有用。