2017-08-24 133 views
0

下面是我對earlGrey測試代碼導航問題

EarlGrey.select(elementWithMatcher: grey_accessibilityID("userNameTextField")) 
.atIndex(0).perform(grey_typeText("[email protected]")) 
EarlGrey.select(elementWithMatcher: grey_accessibilityID("passwordTextField")) 
    .atIndex(1).perform(grey_typeText("[email protected]")) 
EarlGrey.select(elementWithMatcher: grey_accessibilityID("signIn")).atIndex(2) 
    .perform(grey_tap()) 

/////////////////This button on the other view controller i redirect after login////////////////////////////////  
EarlGrey.select(elementWithMatcher: grey_accessibilityID("menuButton")) 
.perform(grey_tap()) 

視圖層次不顯示我的導航view.How可以用我伯爵茶UI在迅速

+0

您是否能夠在層次結構中看到它?使用'[GREYElementHierarchy hierarchyStringForAllUIWindows];' –

+0

否視圖層次結構中,我能夠看到當前視圖沒有導航一個 –

+0

我不能完全理解你的問題。你是說最後一行你點擊menuButton失敗,因爲它找不到按鈕?你能附上失敗日誌嗎? – khandpur

回答

1

我在實現找到解決方案我自己。需要灰色條件。下面是代碼

GREYCondition(name: "Wait for menu button to appear", block: { _ in 
      let errorOrNil = UnsafeMutablePointer<NSError?>.allocate(capacity: 1) 
      errorOrNil.initialize(to: nil) 

      EarlGrey.select(elementWithMatcher: grey_accessibilityValue("menuButton")).assert(grey_notNil(), error: errorOrNil) 

      let success = errorOrNil.pointee == nil 
      errorOrNil.deinitialize() 
      errorOrNil.deallocate(capacity: 1) 

      return success 
     }).wait(withTimeout: 10.0) 
     EarlGrey.select(elementWithMatcher: grey_accessibilityValue("menuButton")).perform(grey_tap())