Overview
The WebDriver configuration inserenity.conf controls browser automation behavior, including driver selection, capabilities, and Chrome-specific options.
Basic WebDriver Settings
serenity.conf
Driver Configuration
Specifies the browser to use for test execution.Supported values:
chrome, firefox, edge, safariEnables Selenium Manager to automatically download and manage browser drivers.When set to
true, you don’t need to manually download ChromeDriver or other browser drivers - Selenium Manager handles this automatically.Selenium Manager (autodownload) was introduced in Selenium 4.6+ and eliminates the need for manual driver management. It automatically downloads the correct driver version matching your installed browser.
Browser Capabilities
Standard Capabilities
Explicitly sets the browser name for WebDriver capabilities.Value:
chromeAllows the browser to accept self-signed or invalid SSL certificates.Essential for testing applications in QA/Staging environments that may use self-signed certificates.
Chrome Options
Thegoog:chromeOptions section configures Chrome-specific behavior through command-line arguments:
Chrome Arguments Explained
remote-allow-origins=*
remote-allow-origins=*
Purpose: Allows remote connections from any originWhy needed: Required for ChromeDriver 109+ to accept connections from test frameworks. Prevents CORS-related connection issues between the test runner and browser driver.Impact: Essential for test execution to work properly with recent Chrome versions.
start-maximized
start-maximized
Purpose: Launches the browser window in maximized stateWhy needed: Ensures consistent viewport size across test runs and prevents element visibility issues that can occur with smaller windows.Impact: Improves test stability by providing maximum screen space for interactions.
incognito
incognito
Purpose: Opens Chrome in incognito (private) modeWhy needed: Starts with a clean slate - no cookies, cache, or browsing history. Each test session is isolated from previous runs.Impact: Prevents test pollution from cached data and ensures repeatable test conditions.
disable-infobars
disable-infobars
Purpose: Disables Chrome’s information barsWhy needed: Removes the “Chrome is being controlled by automated test software” banner that can interfere with element location.Impact: Cleaner test execution without UI distractions.
disable-gpu
disable-gpu
Purpose: Disables GPU hardware accelerationWhy needed: Prevents GPU-related crashes in headless or CI environments where GPU may not be available or properly configured.Impact: Increases stability in containerized and CI/CD environments.
disable-default-apps
disable-default-apps
Purpose: Prevents Chrome from installing default appsWhy needed: Speeds up browser startup by skipping default app installation/checking.Impact: Faster test execution, especially for multiple test runs.
disable-popup-blocking
disable-popup-blocking
Purpose: Disables Chrome’s built-in popup blockerWhy needed: Allows tests to interact with legitimate popup windows without being blocked.Impact: Essential if your application uses popups for authentication, dialogs, or other features.
disable-dev-shm-usage
disable-dev-shm-usage
Purpose: Disables the use of
/dev/shm shared memoryWhy needed: Prevents crashes in Docker containers or environments with limited shared memory (default is 64MB in Docker).Impact: Critical for running tests in containerized CI/CD pipelines.no-sandbox
no-sandbox
Purpose: Disables Chrome’s sandbox security featureWhy needed: Required for running Chrome in Docker containers or environments without proper sandboxing support.Impact: Enables test execution in restricted environments like Docker, but should be used carefully.
Headless Mode
To run tests in headless mode (without visible browser window), add the headless argument:Use
headless=new instead of the deprecated --headless flag for Chrome 109+. The new headless mode provides better compatibility and performance.Browser Resolution
Set a specific browser window size:serenity.conf
Common resolutions:
- 1920x1080: Full HD desktop
- 1366x768: Common laptop
- 414x896: iPhone XR/11
- 375x667: iPhone SE
Additional Chrome Options
Download Behavior
User Agent Override
Multiple Browser Support
Override Browser at Runtime
Browser-Specific Configuration
serenity.conf
Troubleshooting
ChromeDriver Version Mismatch
Tests Failing in CI/CD
Ensure these arguments are present for Docker/CI environments:Element Not Visible Errors
If elements aren’t visible:- Verify
start-maximizedis enabled - Or set explicit window size:
"window-size=1920,1080" - Check if viewport size matches your responsive design breakpoints
SSL Certificate Errors
EnsureacceptInsecureCerts = true is set in capabilities for QA/Staging environments.
Best Practices
Keep autodownload Enabled
Let Selenium Manager handle driver versions automatically
Use Incognito Mode
Ensures clean test state without cached data
Maximize or Set Fixed Size
Prevents element visibility issues
Test with Headless
Verify tests work in headless mode for CI/CD