I want to create some basic headless Login View E2E tests with TestBench for Vaadin24 according the tutorial in https://vaadin.com/docs/latest/tutorial/e2e-testing-with-testbench#test-the-login-view. Nevertheless, the Firefox window is always shown, whether with firefoxOptions.addArguments("-headless"); or without. I use selenium firefox driver 4.14 and latest geckodriver 0.33.
With the headless argument, the window is show but without any html content, only the menu, navigation elements etc. are shown, but no content. Without the headless argument, everything is shown as expected. I’ve tried the https://github.com/vaadin/testbench-demo as well with same result: if I enable headless mode in AbstractIT.java, in this case the Chrome window is shown, no headless mode is available.
How can I enable true headless mode for E2E tests ?
Hi @yummy-rhino thank you for your respnse. Unfortunately, the method options.setHeadless(true);is removed from the API in the version, Testbanch/Selenium for Vaadin 24 is using. Due to https://www.selenium.dev/blog/2023/headless-is-going-away/ one should use options.addArguments("-headless") but this doesn’t work.
I’m using the latest of everything (including chrome 119) and ChromeOptions::addArguments(“headless”) works in our docker container - which normally have no UI
Sorry, but this doesn’t work, neither with a clean skeleton project from vaadin starter. To reproduce the behaviour:
go to start.vaadin.com and load the pre-defined Hello World Project with VaadinFlow 24, Java17, Maven + Spring Boot (3.1.5)
this skeleton project already contains an E2E test MainViewIT.java.
start the Application.java, then start the test (either in your IDE or via mvn clean integration-test -DMainViewIT -Pit => browser windows (Chrome per default) is opened and you see the view provided by the application, test succeeds
ChromeOptions options = new ChromeOptions();
options.addArguments("--headless", "--disable-gpu");
setDriver(new ChromeDriver(options));
run the test again
On my machine ( MacStudio with Apple Silicon (Apple M1 Max, MacOS Ventura 13.5.1 (22G90), Java 17 (Eclipse Temurin 17.0.8 via SDKMAN), Maven 3.9.4) I’ve got the following
browser windows is opened
no content within (as compared to the main view shown in non-headless mode)
test succeeds
The same behavoiur with firefox.
There are no webdrivers (neither geckodriver nor chromedrive) in my path.