2

I am setting up some ui tests with the new ui testing feature of xcode7 but am having a little difficulty figuring out how to set a textfield value to "" without pushing the delete button a whole bunch of times. How can I do this

my testing code:

func testLogin(){

        let app = XCUIApplication()
        let requiredTextField = app.textFields["required"]

        requiredTextField.tap()


        //here is where i want to set it to ""
        requiredTextField.typeText("username1")
        app.typeText("\r")
        ...
Senseful
  • 86,719
  • 67
  • 308
  • 465
BluGeni
  • 3,378
  • 8
  • 36
  • 64

2 Answers2

0

Have you tried something like

requiredTextField.pressForDuration:0.5()
app.menuItems[@"Select All"].tap()
app.menuItems[@"Cut"].tap()
EEGPDX
  • 1
  • 2
0

You can first do a double tap that will highlight the whole textfield, then directly input your new text.

requiredTextField.doubleTap()
requiredTextField.typeText("yourNewText")
SeaJelly
  • 1,738
  • 1
  • 15
  • 30