Configuring waiting behavior
Kolibrium lets you fine-tune how long and how often it waits while locating elements. You can control polling interval, timeout, error message, and which exceptions to ignore using WaitConfig.
val className by driver.className(
value = "by-class-name",
waitConfig = WaitConfig.Default.copy(
pollingInterval = 250.milliseconds,
timeout = 5.seconds,
message = "Element could not be found"
)
)
Under the hood, a FluentWait instance is being configured for the element lookup.
Kolibrium automatically ignores org.openqa.selenium.NoSuchElementException during waits. You do not need to add it to WaitConfig.
Additionally, since Kolibrium relocates the element by default when a StaleElementReferenceException occurs, you don't need to include StaleElementReferenceException in the ignored exceptions list.
Predefined wait configurations for common use cases
Kolibrium provides three presets via WaitConfig: WaitConfig.Default, WaitConfig.Quick, and WaitConfig.Patient. You can use them as-is or tweak them with copy().
| Configuration | Polling interval | Timeout | Default message | Description |
|---|---|---|---|---|
WaitConfig.Default | 200 milliseconds | 10 seconds | "Condition not met within timeout" | Balanced preset suitable for most scenarios. |
WaitConfig.Quick | 100 milliseconds | 2 seconds | "Condition not met within timeout" | Fast preset for responsive applications. |
WaitConfig.Patient | 500 milliseconds | 30 seconds | "Condition not met within timeout" | Extended waits for slower operations. |
Customizing wait configurations
The copy() function allows you to easily modify existing wait configurations. You can change any combination of
pollingIntervaltimeoutmessageignoring(set of exceptions to ignore)
val className by driver.className(
value = "by-class-name",
waitConfig = WaitConfig.Default.copy(timeout = 5.seconds)
)
Potential configuration errors
The WaitConfig configuration includes runtime checks that will throw an IllegalArgumentException if:
pollingIntervalis negativepollingIntervalis less than 10 millisecondstimeoutis negativetimeoutis less than 100 millisecondspollingIntervalis greater thantimeout