Package io.karatelabs.driver
Interface DriverProvider
- All Known Implementing Classes:
PooledDriverProvider
public interface DriverProvider
Provider for browser driver instances.
Implementations can manage driver lifecycle in different ways:
- Per-scenario: create new driver for each scenario (default behavior)
- Per-thread: reuse driver within same thread (ThreadLocal pattern)
- Pooled: maintain a pool of drivers, borrow/return
Example usage with Runner:
Runner.path("features/")
.driverProvider(new CdpPooledProvider(browserWsUrl))
.parallel(4);
-
Method Summary
Modifier and TypeMethodDescriptionacquire(ScenarioRuntime runtime, Map<String, Object> config) Acquire a driver instance for a scenario.voidrelease(ScenarioRuntime runtime, Driver driver) Release a driver instance after scenario completion.voidshutdown()Shutdown the provider and close all managed drivers.
-
Method Details
-
acquire
Acquire a driver instance for a scenario.Called when a scenario first accesses the driver (lazy initialization). The provider may create a new driver, return one from a pool, or return a thread-local cached instance.
- Parameters:
runtime- the scenario runtime requesting the driverconfig- driver configuration fromconfigure driver = {...}- Returns:
- a driver instance
-
release
Release a driver instance after scenario completion.Called when a scenario ends. The provider may close the driver, return it to a pool, or keep it cached for the thread.
- Parameters:
runtime- the scenario runtime that used the driverdriver- the driver to release
-
shutdown
void shutdown()Shutdown the provider and close all managed drivers.Called when the Suite completes. All drivers should be closed.
-