assets are not loaded in functional test mode assets are not loaded in functional test mode selenium selenium

assets are not loaded in functional test mode


Finally, here's the solution to this problem.

I added this line to my build.sbt file :

For SBT 0.x:

unmanagedResourceDirectories in Test <+=  baseDirectory ( _ /"target/web/public/test" )

For SBT 1.x:

unmanagedResourceDirectories in Test +=  baseDirectory ( _ /"target/web/public/test" ).value

Thanks to @MarkVedder and @JarmoPertman for their great comments who put me on this solution!


For others that come looking for a solution to this, we were having problems getting assets to load properly in our functional test run under Scala 2.12 and Play Framework 2.6. Following the advice on the accepted answer here, we tried adding:

unmanagedResourceDirectories in FunctionalTest +=   baseDirectory ( _ /"target/web/public/test" ).value

And that appeared to work - at least locally. However, things were still failing on our CI side. Mentioned in another comment here was this old Play Framework issue: https://github.com/playframework/playframework/issues/3234, we tried adding the web-test:assets command prior to running our functional test suite, and that also appeared to fix it as we could see locally that the assets got moved into the target/web/public/test directory. Still having problems though getting it to consistently pass or pass at all on our CI side.

Knowing that sbt-web was involved in this process, going back over the sbt-web docs there was a little hidden item in the readme on https://github.com/sbt/sbt-web:

To automatically add the production-ready assets to classpath, the following might be useful:

(managedClasspath in Runtime) += (packageBin in Assets).value

Modifying that line slighty to work with our FunctionalTest config:

(managedClasspath in FunctionalTest) += (packageBin in Assets).value

and now it is passing ALL THE TIME both locally and on CI. No other SBT lines were needed, and we REMOVED the

unmanagedResourceDirectories in FunctionalTest +=  baseDirectory ( _ /"target/web/public/test" ).value

line as it was no longer needed.


I recently had a similar problem. I solved it double checking this steps according to Play 2.3 Migration guide:

1.- Check if sbt.version is set to 0.13.5 in your /project/build.properties file.

2.- Add sbt-web plugin in your project/plugins.sbt file: addSbtPlugin("com.typesafe.sbt" % "sbt-web" % "1.0.2")

3.- Enable SbtWeb plugin in your /build.sbt file like thislazy val root = (project in file(".")).enablePlugins(PlayJava, SbtWeb)

Let me know if this solved your problem.