KasperskyLab / Kaspresso

Android UI test framework
https://kasperskylab.github.io/Kaspresso/
Apache License 2.0
1.81k stars 154 forks source link

Unresolved reference for flakySafely #644

Closed crazyvan closed 6 months ago

crazyvan commented 6 months ago

Hi,

I've just started using Kaspresso and the first test I've written works fine until I attempt to use 'flakySafely'. Android Studio reports that 'flakySafely' is not available for the following Kotlin object:

import com.kaspersky.kaspresso.screens.KScreen
import io.github.kakaocup.kakao.text.KButton

object WelcomeScreen : KScreen<WelcomeScreen>() {
    override val layoutId: Int? = null
    override val viewClass: Class<*>? = null

    private val logInButton: KButton =  KButton { withContentDescription("login button") }
    private val registerButton: KButton = KButton { withContentDescription("register button") }

    fun tapLogInButton() {
        WelcomeScreen {
            logInButton {
                isVisible()
                isEnabled()
                click()
            }
        }
    }

    fun tapRegisterButton() {
        WelcomeScreen {
            flakySafely(15000) {
                registerButton {
                    isVisible()
                    isEnabled()
                    click()
                }
            }
        }
    }
}
Screenshot 2024-05-18 at 18 06 25

Not sure why. Is there particular version of Kotlin that I should be using? The project is on 1.8.20.

And in app/build.gradle I have: androidTestImplementation 'com.kaspersky.android-components:kaspresso:1.5.3' androidTestUtil 'androidx.test:orchestrator:1.4.2'

crazyvan commented 6 months ago

Figured it out. This works:

 run {
                WelcomeScreen {
                    flakySafely(3000) {
                        logInButton {
                            isVisible()
                        }
                    }
                }
        }