ulfsauer0815 / assertj-jsoup

AssertJ assertions for HTML

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AssertJ assertions for HTML

build Maven JitPack coveralls codecov

Provides assertions for HTML content including a Kotlin DSL. Uses jsoup for parsing.

Example

Kotlin DSL

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() }
    }
}

Java / Kotlin

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 configuration

Kotlin

build.gradle.kts

repositories {
    mavenCentral()
}

testImplementation("io.github.ulfs:assertj-jsoup:0.1.4")

Gradle

build.gradle

repositories {
    mavenCentral()
}

testImplementation "io.github.ulfs:assertj-jsoup:0.1.4"

Development

see DEVELOPMENT.md

About

AssertJ assertions for HTML

License:MIT License


Languages

Language:Kotlin 98.8%Language:Shell 0.8%Language:HTML 0.2%Language:Java 0.2%