Buggy Login kif UITest Swift

103 Views Asked by At

I am trying to make a simple login UITest but I am getting some strange error which I don't understand.

In my test file I have:

override func beforeEach() {
    super.beforeAll()
    super.beforeEach()
   }


func testLogin() {
    let app = XCUIApplication()


    let loginButtonOne = app.buttons["LOGIN"]
    expectation(for: exists, evaluatedWith: loginButtonOne, handler: nil)
    waitForExpectations(timeout: 5, handler: nil)
    loginButtonOne.tap()


    let loginButtonTwo = app.buttons["LOGIN"]
    fillInEmail()
    fillInCorrectPassword()
    loginButtonTwo.tap()


    tester().waitForView(withAccessibilityLabel: "PracticeViewController")

I also have an extension where I have:

 func fillIn(_ accessibilityLabel: String, withText text: String) {
    tester().clearText(fromAndThenEnterText: text, intoViewWithAccessibilityLabel: accessibilityLabel)
}    

func fillInEmail() {
    fillIn("EMAIL", withText: correctUsername)
}

func fillInCorrectPassword() {
    fillIn("PASSWORD", withText: correctPassword)
 }
}

My issue is in the fillIn Method. When I try run the test it fails and an error pops up saying: caught "NSInvalidArgumentException",**** -[_NSArrayM insertObject:atIndex] object cannot be nil"

Thanks!

0

There are 0 best solutions below