2016-10-23 17 views
0

私は、テーブル・ビュー・セルを削除するスワイプが実際にテーブル・ビューからセルを削除するという基本的なショッピング・リスト・アプリケーションでUIテストを作成しようとしています。UIスワイプ・テーブル・ビュー・セルの削除をテストする

私は以下のテストコードを実行していますが、テーブルビューのセルを左にスワイプして(削除ボタンを表示する)スワイプしません。それはそれをタップしているかもしれないが、それはスワイプされていないようです。このため、「ボタンに一致するものが見つかりません」という理由で、削除ボタンをタップしようとするとテストが失敗します。

テーブルビューでスワイプを削除する方法を教えてください。

func testDeletingCell() { 
     let app = XCUIApplication() 
     app.navigationBars["ShoppingList.ShoppingListView"].buttons["Add"].tap() 

     let element = app.otherElements.containing(.navigationBar, identifier:"ShoppingList.AddShoppingListItemView").children(matching: .other).element.children(matching: .other).element.children(matching: .other).element 
     let textField = element.children(matching: .textField).element(boundBy: 0) 
     textField.tap() 
     textField.typeText("abc") 

     let textField2 = element.children(matching: .textField).element(boundBy: 1) 
     textField2.tap() 
     textField2.typeText("123") 
     app.navigationBars["ShoppingList.AddShoppingListItemView"].buttons["Save"].tap() 

     let tablesQuery = app.tables 
     tablesQuery.children(matching: .cell).element(boundBy: 0).staticTexts["123"].swipeLeft() 
     tablesQuery.buttons["Delete"].tap() 

     XCTAssert(app.tables.cells.count == 0) 
    } 
+0

が正しく発見さ123要素ですか?あなたがシミュレータを見ていると、それは実際にスワイプされていますか? –

答えて

6

代わりに、この新しいSwift 3構文を試してみてください:

let tablesQuery = app.tables.cells 
tablesQuery.element(boundBy: 0).swipeLeft() 
tablesQuery.element(boundBy: 0).buttons["Delete"].tap() 
+0

これが答えでした。ありがとう、Rashwan。 – Josh

+0

@Josh、np喜んで助けてください。 –

関連する問題