What is the best way to initialize a variable with the Selenium's FindBy annotation in Kotlin?
Something like
@FindBy(id = "example")
private lateinit var button: WebElement
or
@FindBy(id = "example")
private val button: WebElement? = null
or
@FindBy(id = "example")
private var button: WebElement? = null
or something else?
Note that all the previous methods works perfectly.
The second option likely will not work, because the
valis already initialized tonulland cannot be changed.I believe using the
lateinitis the way to go in this case. It's meant for this purpose mainly.