Installation (Gradle)

implementation group: "org.http4k", name: "http4k-testing-webdriver", version: ""


A basic Selenium WebDriver API implementation for http4k HttpHandlers, which runs completely out of container (no network) for ultra fast tests, backed by JSoup.

Feature Supported Notes
Navigation yes simple back/forward/refresh history
CSS selectors yes
Link navigation yes
Form field entry and submission yes
Cookie storage yes manual expiry management
JavaScript no
Alerts no
Screenshots no
Frames no
Multiple windows no

Use the API like any other WebDriver implementation, by simply passing your app HttpHandler to construct it. Note that we now support version 4 of the API, which has deprecated the old By implementations. http4k ships with a custom set of JSoup By implementations, so be sure to import org.http4k.webdriver.By instead of the old org.openqa.selenium.By ones (which will fail with a ClassCastException when used).


package guide.reference.webdriver

import org.http4k.core.Method.GET
import org.http4k.core.Response
import org.http4k.core.Status.Companion.OK
import org.http4k.routing.bind
import org.http4k.routing.routes
import org.http4k.webdriver.Http4kWebDriver
import org.openqa.selenium.By

fun main() {
    val app = routes(
        "/hello" bind GET to {

    val driver = Http4kWebDriver(app)




// prints:
// hello
// <title>hello</title>