2016-04-14 33 views
43

我試圖在Xcode中生成UItest。當我嘗試刷卡的UIView我得到 一個錯誤:時間戳事件匹配錯誤:無法找到匹配的元素

Timestamped Event Matching Error: Failed to find matching element 

error window

enter image description here

,如果我嘗試挖掘的UIView也會發生這種情況。

+0

你能解釋一點嗎? –

+0

我嘗試滑動或輕擊UIview,假設做某事(有姿態重建器),但當我做手勢時,發生此錯誤。 我管理的唯一辦法是使其工作是查詢,但它真的很複雜,我敢肯定,有另一種方式 – shay

+0

我有完全相同的問題 –

回答

0

對於錄製新測試,我認爲還沒有解決方案。但是,如果您使用擴展強制攻擊與已經存在的測試一起工作。使用

例子:

extension XCUIElement { 

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

func testSomethingWithCells() { 

    let app = XCUIApplication() 
    let cells = app.tables.cells 
    sleep(1) 
    cells.elementBoundByIndex(0).forceTapElement() 
} 

您可以查看原帖在這裏:

Xcode UI test - UI Testing Failure - Failed to scroll to visible (by AX action) when tap on Search field "Cancel' button

35

您應該驗證「輔助功能」選項是UIView的啓用對象,你是刷卡來自,例如:

enter image description here

+2

這就是爲了我。這個答案應該被接受! – user1366265

+0

在WebView中解析文本時,爲WebView旋轉輔助功能使我的測試失敗。關閉託管WebView的UIView,關閉輔助功能,使測試成功。所以要小心。 – askielboe

+0

另一點讓它適合我,我不得不給它一個標籤 – SeanLintern88

0

我一直偶爾遇到這個問題。從DerivedData中刪除應用程序的目錄似乎有所幫助。

0

爲我自己工作的解決方案是以不同的方式識別對象。
在Xcode中8我可以使用以下命令:

XCUIApplication().tables.cells["Camera Roll"].buttons["Camera Roll"].tap() 

和Xcode 9我在這個問題提到的錯誤。結束使用以下,哪些工作(比原來的選項更多的flappy

XCUIApplication().cells.element(boundBy: 1).tap()