Search code examples
seleniumselenium-chromedriverheadlessserenity-bdd

Serenity test error element not available in headless mode


The scenario is:

I have serenity tests that i launch with chromedriver that work When i launch the tests without headless option the tests are "passed" while with the headless mode the tests are failed with error: net.serenitybdd.core.exceptions.SerenityManagedException: The following error occurred: Timed out after 5 seconds. Element not available

here the line command that launch the test : mvn clean verify -Dwebdriver.driver=chrome

And the serenity.properties:

  • webdriver.chrome.driver = chromedriver
  • webdriver.base.url= ********
  • webdriver.timeouts.implicitlywait=5000
  • chrome.switches=--headless;
  • serenity.browser.maximized = true

Solution

  • The solution is to add in chrome.switches --window-size=1920,1080;

    • chrome.switches=--window-size=1920,1080;--headless;