I’m running Selenium tests with Cucumber in a Jenkins pipeline from a Vaadin Java Spring project. My tests use ChromeDriver in headless mode and are configured with Serenity BDD (Thucydides). The setup typically runs 271 tests, and occasionally all tests pass, but sometimes several tests fail randomly with a DriverConfigurationError with a failed job status.
The error message I see when tests fail is:
net.thucydides.core.webdriver.DriverConfigurationError: WebDriver was unable to create a new instance of type class org.openqa.selenium.chrome.ChromeDriver WebDriver reported the following message: Unable to obtain: Capabilities {acceptInsecureCerts: false, browserName: chrome, goog:chromeOptions: {args: [remote-allow-origins=*, --headless=new --dns-prefet...], extensions: []}}, error Failed to parse json output, executed: [--browser, chrome, --output, json]
The error often appears in the newWebDriverInstance method:
net.thucydides.core.webdriver.WebDriverFactory.newWebdriverInstance(WebDriverFactory.java:152) net.thucydides.core.webdriver.WebDriverFacade.newDriverInstance(WebDriverFacade.java:178) net.thucydides.core.webdriver.WebDriverFacade.newProxyDriver(WebDriverFacade.java:169) net.thucydides.core.webdriver.WebDriverFacade.getProxiedDriver(WebDriverFacade.java:120) net.thucydides.core.webdriver.WebDriverFacade.get(WebDriverFacade.java:209)
My Setup:Headless Mode: Using Chrome in headless mode.Chrome Options: --headless=new --dns-prefetch-disable --no-first-run --homepage=about:blank --disable-extensions --test-type --no-sandbox --disable-dev-shm-usage --disable-default-apps --disable-infobars --disable-gpu --disable-extensions-file-access-check --disable-prompt-on-repost --mute-audioPipeline Environment: Jenkins CI/CD with a virtual display (Xvfb).Tooling: Serenity BDD (Thucydides), Cucumber, Selenium.
Question:How can I achieve consistent test results in Jenkins and eliminate the DriverConfigurationError caused by Failed to parse JSON output? Could this error be related to specific Chrome flags, or is it potentially an issue with the Jenkins pipeline configuration or resources?
Any insights or suggestions to stabilize the test execution would be greatly appreciated!
Troubleshooting Steps Taken:Verified that ChromeDriver and Chrome versions match using WebDriverManager.Tried switching --headless=new to --headless for stability.serenity.restart.browser.for.each several option variations in serenity.propertiesCalling driver.quit() instead of driver.close() after each scenario.Despite these changes, the error persists intermittently. I suspect it may be due to timing or resource limitations, but it’s unclear why the error is inconsistent.