I’m facing issues with selenium click commands while testing my web application built on Play Framework. When I execute the tests using play run in a normal browser, everything operates smoothly. However, when I switch to headless mode using play auto-test, the click commands seem to fail.
In the browser, all of these commands succeed, but in headless auto-test mode, they don’t work. Specifically, using clickAndWait results in a timeout after 30 seconds, and regular click commands fail because the assertion for the next page keeps referencing the old page.
I’ve also tried adding commands like waitForElementPresent and waitForPageToLoad before the click, but it hasn’t helped. Has anyone else encountered similar problems with headless testing in Play Framework?
I’ve hit this exact issue with Play Framework headless testing. Usually it’s CSS rendering or positioning acting weird without a full browser. Your button’s probably there but not actually clickable - CSS transforms and positioning get screwy in headless mode. Check element.isDisplayed() before clicking, and try targeting by CSS class instead of name. I’ve had way better luck with click(‘css=.btn.btn-green’) than name attributes in headless. Here’s what saved me tons of time: enable screenshots in headless mode so you can see what selenium actually sees. Half the time the page layout is completely different than you’d expect.
headless mode’s a pain with play framework. switch to phantomjs or chrome headless - the default one sucks. half the time it’s just a version mismatch between your selenium driver and play’s test setup. also check if that button needs a hover first. i’ve seen css :hover states completely break clicks in headless mode while working fine in regular browsers.
I had the same headless mode issue with Play Framework testing. The problem is timing - headless mode handles JavaScript and DOM updates differently than regular browsers, so you’re clicking before things are ready. I fixed it by using explicit waits for element interactivity, not just presence. Use WebDriverWait with ExpectedConditions.elementToBeClickable() before clicking. Also check that the button isn’t hidden behind other elements during test execution. What worked for me was adding a short pause after page transitions in headless mode. The DOM loads but JavaScript event handlers aren’t attached yet. If selenium clicks keep failing, try using JavascriptExecutor to trigger the click directly.