Skip to content

Extension functions to make Selenide tests with Kotlin awesome

License

Notifications You must be signed in to change notification settings

strangeway-org/selenide-kelt

Repository files navigation

Kelt Helmet

Selenide Kelt

Extension functions to make Selenide tests with Kotlin awesome!

license Download

Maven dependency:

Gradle:

repositories {
    maven {
        url "https://dl.bintray.com/strangeway-org/libs" 
    }
}

dependencies {
    testImplementation "org.strangeway:selenide-kelt:1.1.0"
}

Examples:

  1. Get element by any of standard By (with named arguments instead of By):

    open("/login")
    
    // search by CSS as simple as possible:
    elt("#submit").click()
    
    // or you may specify selector explicitly:    
    elt(css = "#submit").click()
    elt(cssClass = "message").shouldHave(text("Hello"))
    
    elt(text = "Sign in").click()
    elt(name = "password").setValue("qwerty").pressEnter()
    
    elt(xpath = "//*[@id='search-results']//a[contains(text(),'selenide.org')]").click()
  2. Or many elements:

    elts(id = "search-results").shouldBe(visible)
    elts("#search-results a").elt(text = "selenide.org").click()
  3. Element inside of elements:

    elt(tag = "header").elt(id = "menu").click()
    elt(tag = "header").elts(cssClass = "item").shouldHave(size(5))
  4. Build PageObject classes easier:

    import org.strangeway.kelt.*
    
    class GoogleResultsPage {
        val results = elt(id = "results")
    }
    
    class GoogleSearchPage {
        private val searchBox = elt(name = "q")
    
        fun search(query: String): GoogleResultsPage {
            searchBox.setValue(query).pressEnter()
            return page() // no need to duplicate <GoogleResultsPage> type
        }
    }
    
    // ...
    openPage<GoogleSearchPage>("http://google.com").search("Selenide!")
    
    // get page on demand without opening
    val googlePage = page<GoogleResultsPage>()

If you want to support the project

Buy Me A Coffee

About

Extension functions to make Selenide tests with Kotlin awesome

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages