使用XCTestCase的UITest无法找到searchBar

时间:2017-09-19 09:28:01

标签: ios swift fastlane xctestcase

我在故事板文件中的字段如下:

<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>

我的UITest使用fastlane代码,如下所示:

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
}

但它总是引发错误:类型'XCUIElementType'没有成员'searchBar'

请帮帮我。

0 个答案:

没有答案