멋있게걷는방법

[UITest] password textFiled 에 tap 이 안 될 때? 본문

iOS

[UITest] password textFiled 에 tap 이 안 될 때?

도현D 2023. 4. 4. 17:57

이걸로 하루의 절반을 날렸습니다..

    private let inputPasswordTextField = UITextField().then {
        $0.accessibilityIdentifier = "inputPasswordTextField"
        $0.placeholder = "비밀번호"
        $0.layer.borderColor = UIColor.clear.cgColor
        $0.layer.borderWidth = 1
        $0.setPlaceholder(color: UIColor.gray)
        $0.layer.cornerRadius = 8
        $0.isSecureTextEntry = true
        $0.backgroundColor = .blue
    }

현재 제 passwordTextField 는 이렇습니다.

이를 바탕으로 UITest 를 시도했습니다.

 

    override func setUpWithError() throws {
        // Put setup code here. This method is called before the invocation of each test method in the class.

        // In UI tests it is usually best to stop immediately when a failure occurs.
        continueAfterFailure = false
        
        app = XCUIApplication()
        app.launch()

        skipButton = app.buttons["Skip"]
        emailTF = app.textFields["inputEmailTextField"]
        passwordTF = app.textFields["inputPasswordTextField"]
        signInButton = app.buttons["signInButton"]
    }

    func testSignInViewController_notRegistedUser_isVisibleWarningLabel() {
        skipButton.tap()
        emailTF.tap()
        emailTF.typeText("asdf123@naver.com")
        app.tap()
        
        passwordTF.tap()
        passwordTF.typeText("12345678")

        XCTAssertEqual(signInButton.isEnabled, true)
    }

하지만 이러한 에러를 마주했습니다ㅠㅠ..

이유는..

inputPasswordTextField 의 isSecureTextEntry 가 True 이기 때문입니다.

해결 방법은

passwordTF = app.secureTextFields["inputPasswordTextField"]

이렇게 isSecureTextEntry 가 True 라면 secureTextFields 로 설정해주면 에러를 해결할 수 있습니다.

이런걸로 삽질했다는게 너무 허무하네요..