I have been working with BDD Test automation since 3 years now that used Neodymium 4.1.5 version with Java 11. recently since 2 months I am facing issue with Chrome Headless mode execution where browser size is not maximized which use to worked all fine earlier. Due this element clicks are not functioning as it would hidden or need to be scrolled either way. Non Headless mode works all fine without any issue. Issue is reproducible in local and also on Jenkins agent as well. I am unable to figure out the root cause for this issue, we have chrome 138.x version , and I se with Selenium 4.x it has capability to detect and download the required version chrome driver..
Properties we set up are as below
browserprofile.Chrome.name=Chrome
browserprofile.Chrome.browser=chrome
browserprofile.Chrome.browserResolution=1920x1080
browserprofile.Chrome.headless=true
browserprofile.Chrome.arguments=-ignore-certificate-errors --disable-gpu
neodymium.url=https://${neodymium.url.host}
neodymium.url.host= <hostname>
neodymium.locale=en-US
neodymium.debugUtils.highlight=true
neodymium.debugUtils.highlight.duration=100
neodymium.allureAddons.screenshots.perstep.always=true
neodymium.webDriver.reuseDriver=false
neodymium.webDriver.keepBrowserOpen=false
neodymium.webDriver.keepBrowserOpenOnFailure=false
neodymium.selenideAddons.staleElement.retry.count=2
neodymium.selenideAddons.staleElement.retry.timeout=10000
neodymium.webDriver.window.width=1920
neodymium.webDriver.window.height=1080
@Before
public void before(Scenario scenario) throws IOException {
var driverVersion = System.getenv("DRIVER_VERSION");
var browserVersion = System.getenv("BROWSER_VERSION");
if (driverVersion != null) {
WebDriverManager.chromedriver()
.driverVersion(driverVersion)
.browserVersion(browserVersion)
.setup();
} else {
WebDriverManager.chromedriver().setup();
}
WebDriverUtils.setUp("Chrome");
TimezoneUtils.setTimezoneDiffInSecondsFromProperties();
TrustAllCertificates.install();
currentScenario = scenario;
if (scenario.getStatus() == Status.UNDEFINED) {
throw new PendingException("Scenario has undefined steps: " + scenario.getName());
}
}
This is a change in Chrome headless mode behavior in recent versions (Chrome 138+).
In non-headless mode maximize() works fine, but in headless mode Chrome ignores it, so your neodymium.webDriver.window.width/height properties are not applied. That’s why elements appear hidden or need scrolling.
The fix is to explicitly set a window size via Chrome arguments:
browserprofile.Chrome.arguments=--ignore-certificate-errors --disable-gpu --headless=new --window-size=1920,1080
Remove the neodymium.webDriver.window.width/height lines, since headless won’t respect them.
If you still want to enforce sizing in code, you can add after driver setup:
WebDriver driver = WebDriverUtils.getWebDriver();
driver.manage().window().setSize(new Dimension(1920, 1080));
With --window-size specified, headless execution will match non-headless and element clicks should work again both locally and in Jenkins.