com.github.mvysny.kaributesting.v10.LocatorAddons.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of karibu-testing-v10 Show documentation
Show all versions of karibu-testing-v10 Show documentation
Karibu Testing, support for browserless Vaadin testing in Kotlin
package com.github.mvysny.kaributesting.v10
import com.vaadin.flow.component.Component
import com.vaadin.flow.component.HasText
import java.util.function.Predicate
/**
* Makes sure that the component's [Component.caption] contains given [substring].
*/
fun SearchSpec.captionContains(substring: String) {
predicates.add(CaptionContainsPredicate(substring))
}
private data class CaptionContainsPredicate(val substring: String) : Predicate {
override fun test(t: T): Boolean = t.caption.contains(substring)
override fun toString() = "captionContains('$substring')"
}
/**
* Makes sure that the component's [HasText.getText] contains given [substring].
*/
fun SearchSpec.textContains(substring: String) where T : HasText, T : Component {
predicates.add(TextContainsPredicate(substring))
}
private data class TextContainsPredicate(val substring: String) : Predicate {
override fun test(t: T): Boolean = t.text.contains(substring)
override fun toString() = "textContains('$substring')"
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy