2016-06-07 6 views
1

Hallo, ich bin neu in der UI-Test und schnell.Xcode UI Test-Taste nicht tippen

Was ich versuche zu tun ist nur tippen Sie auf die "+" Schaltfläche in der rechten oberen Ecke und tippen Sie dann auf die "first option", die angezeigt wird. Xcode sagt, dass mein Test erfolgreich ist, aber keiner meiner Taps tut etwas. Hier ist mein Code

func test1() { 
    let app = XCUIApplication() 
    let addButtonButton = app.navigationBars["Timesheets"].buttons["add button"] 
    waitForElementToHittable(addButtonButton) 
    addButtonButton.tap() 

    let tablesQuery = app.tables 
    tablesQuery.cells.elementBoundByIndex(0).forceTap() 
} 

hier ist die Definition für waitForElementToHittable() und forceTap()

func waitForElementToHittable(element: XCUIElement, 
          file: String = #file, line: UInt = #line) { 
    let existsPredicate = NSPredicate(format: "hittable == true") 
    expectationForPredicate(existsPredicate, 
          evaluatedWithObject: element, handler: nil) 

    waitForExpectationsWithTimeout(30) { (error) -> Void in 
     if (error != nil) { 
      let message = "Failed to hit \(element) after 30 seconds." 
      self.recordFailureWithDescription(message, 
               inFile: file, atLine: line, expected: true) 
     } 
    } 
} 

extension XCUIElement { 
    func forceTap() { 
     if self.hittable { 
      self.tap() 
     } else { 
      let coordinate: XCUICoordinate =  self.coordinateWithNormalizedOffset(CGVectorMake(0.0, 0.0)) 
      coordinate.tap() 
     } 
    } 
} 

Jede mögliche Anleitung wäre sehr willkommen. Vielen Dank.

Antwort

0

Sie haben vergessen, die App zu starten:

let app = XCUIApplication() 
app.launch() // missing in your code 
Verwandte Themen