Provides assertions for HTML content including a Kotlin DSL. Uses jsoup for parsing.
assertThatSpec(document) {
node("h1") { exists() }
node(".example-code") { containsText("Kotlin") }
node(".github-link") {
hasText("Fork me on GitHub")
attribute("href") {
containsText("github")
containsText("assertj-jsoup")
}
attribute("target") { hasText("_blank") }
attribute("disabled") { notExists() }
}
}
assertThat(document)
.elementExists("h1")
.elementContainsText(".example-code", "Kotlin")
.elementHasText(".github-link", "Fork me on GitHub")
.elementAttributeContainsText(".github-link", "href", "github")
.elementAttributeContainsText(".github-link", "href", "assertj-jsoup")
.elementAttributeHasText(".github-link", "target", "_blank")
.elementAttributeNotExists(".github-link", "disabled");
build.gradle.kts
repositories {
mavenCentral()
}
testImplementation("io.github.ulfs:assertj-jsoup:0.1.4")
build.gradle
repositories {
mavenCentral()
}
testImplementation "io.github.ulfs:assertj-jsoup:0.1.4"
see DEVELOPMENT.md