What's the command for running Serenity tests in headless mode on a Jenkins server?

I’ve got a problem with my Maven Serenity tests. They work fine on my local machine with Chrome but fail on our Jenkins server. Here’s what I’m dealing with:

  • The Jenkins server is on Red Hat Linux without a GUI
  • It has Firefox installed
  • I’ve included the geckodriver binary in my code
  • When I run the tests, I get a ‘timeout waiting for a browser’ error

I think the solution is to run the tests in headless mode. But I’m not sure how to do this. Can anyone help me figure out the right command to use?

Here’s an example of what I’m currently using:

mvn test -Dwebdriver.driver=firefox -Dheadless.mode=true -Duser.name=testuser -Duser.pass=testpass123

This doesn’t work though. What am I missing? Any tips on getting this to run smoothly on Jenkins would be great. Thanks!

Hey there, I’ve been in a similar situation before with Serenity tests on Jenkins. The command you’re using is close, but there’s a small tweak needed. Try this instead:

mvn clean verify -Dwebdriver.driver=firefox -Dserenity.headless.mode=true -Duser.name=testuser -Duser.pass=testpass123

The key difference is using ‘serenity.headless.mode’ instead of just ‘headless.mode’. Also, I’ve found that using ‘clean verify’ instead of just ‘test’ can help avoid some caching issues.

If you’re still having trouble, make sure your POM file includes the latest Serenity BDD dependencies and the correct Firefox driver version. Also, double-check that Jenkins has the necessary permissions to run the tests.

Hope this helps! Let me know if you need any more details.

I’ve dealt with similar issues running Serenity tests on Jenkins. Your approach is on the right track, but there are a few adjustments that might help:

First, try modifying your command to:

mvn clean verify -Dwebdriver.driver=firefox -Dserenity.headless.mode=true -Dwebdriver.firefox.driver=/path/to/geckodriver

Ensure you specify the correct path to geckodriver. Also, consider adding -Dserenity.browser.maximized=true to avoid potential viewport issues.

If problems persist, check your Jenkins job configuration. Make sure it’s set to use the correct JDK version and that all necessary environment variables are properly set.

Lastly, review your test code. Some WebDriver wait strategies might need adjustment for headless execution. Increasing timeout values could help if network latency is a factor.

hey sparklinggem, try this command:

mvn clean verify -Dwebdriver.driver=firefox -Dserenity.headless.mode=true -Dwebdriver.firefox.driver=/path/to/geckodriver

make sure to replace /path/to/geckodriver with the actual path on ur jenkins server. also check if firefox is up to date. lemme know if u still have issues!