How to obtain reference to TextField in UI Tests in Xcode 7

后端 未结 1 1314
别那么骄傲
别那么骄傲 2021-02-07 23:29

I am trying to use UI tests in xcode 7 beta. I have a storyboard with two text fields. Both text fields have outlets and different Restoration IDs. I recorded the test but gen

相关标签:
1条回答
  • 2021-02-07 23:53

    You need to set accessibility identifier in storyboard for that particular textField. Check the image below :

    So you can query textField using accessibility identifier like this :

    let app = XCUIApplication()
    app.launch()
    
    let nameTextField = app.textFields["nameTextField"]
    nameTextField.tap()
    nameTextField.typeText("Hello John")
    
    0 讨论(0)
提交回复
热议问题