UITest with XCTestCase can not find searchBar

564 views Asked by At

My field in storyboard file like bellow:

<searchBar contentMode="redraw" placeholder="Tìm đầu số cố định" translatesAutoresizingMaskIntoConstraints="NO" id="yT6-iM-naf">
  <rect key="frame" x="0.0" y="148" width="375" height="44"/>
  <textInputTraits key="textInputTraits"/>
  <connections>
      <outlet property="delegate" destination="BYZ-38-t0r" id="0lh-uB-0ML"/>
  </connections>
</searchBar>

My UITest with fastlane code like this:

func testExample() {

    snapshot("0Start")   
    // 2
    //Find searchBar in here
    let search = app
            .otherElements["yT6-iM-naf"]
            .children(matching: .searchBar)
            .element
    //Click in here
    search.tap()

    search.typeText("Ho chi")
    app.keyboards.buttons["Search"].tap()

    // // 3
    snapshot("02Search")    
    // Ending
}

But it alway raise error: type 'XCUIElementType' has no member 'searchBar'

Please help me.

0

There are 0 answers