EarlgreyUI iOS测试中的导航问题

时间:2017-08-24 06:48:25

标签: ios earlgrey

以下是我的earlGrey测试代码

EarlGrey.select(elementWithMatcher: grey_accessibilityID("userNameTextField"))
.atIndex(0).perform(grey_typeText("freshaccount@dayrep.com"))
EarlGrey.select(elementWithMatcher: grey_accessibilityID("passwordTextField"))
    .atIndex(1).perform(grey_typeText("Flower@123"))
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())

视图层次结构不显示我的导航视图。如何在swift中实现我使用earl grey ui

1 个答案:

答案 0 :(得分: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())