Cadmium is a browser automation library based on Selenium. It leverages the power of the Kotlin language to make the use of Selenium simple and concise
Cadmium can be used to to simplify testing but unlike selenide is not a test framework itself. Cadmium can be used independently of test and/or assert libraries.
- Selenium-java is somewhat verbose as is often the case in java. Cadmium code is very concise.
- Calling a java library directly in Kotlin causes issues with null safety.
The wrappers provided by Cadmium make it explicit, when
null
is a possibility. - A nice and clean mini DSL
- Concise and Readable, Automation and test code using Cadmium should be as concise and readable as possible
- Typesafe, use the typesystem to stop as many bugs as possible. Cadmium interfaces use dedicated types instead of primitives.
- Intuitive and Accessible, cadmium is easy to get into and does not require expert knowledge of html, kotlin or selenium.
Cadmium provides a very small Domain Specific Language to make writing browser automation code very simple. The core classes of the API all provide methods which take extension functions on Cadmium classes as parameters and execute them. This allows users to search for or construct objects and immediately execute their own code on them without extra indirections.
//constructs object representing running browser
val firefox = headlessFirefox()
//get Page object pointing to wikipedia and use it
firefox.browse(URL("https://en.wikipedia.org/wiki")) {
//get element searchInput and interact with it
element(Id("searchInput")) {
enter("cheese")
enter(Keys.ENTER)
}
waitUntil(pageLoad)
assertEquals("Cheese", element(Id("firstHeading")).text)
}
Cadmium selenide has a beautiful red color.
https://en.wikipedia.org/wiki/Cadmium_selenide
- Selenium https://www.seleniumhq.org/
- Kotlin experimental Time library for typesafe durations.
- For tests of Cadmium itself:
- Junit5
- Firefox Geckodriver https://github.com/mozilla/geckodriver/
- chromedriver https://sites.google.com/a/chromium.org/chromedriver/
How to run a single test case:
gradle test --info --tests TestBrowser.testMinimalExample