Testing Selenium / Web Drivers with Multiple Browsers with Play Framework

I have no experience with Selenium / WebDriver benchmarks. I know Play supports Selenium out of the box, but frankly, the built-in support doesn't match my expectations:

  • I want to set up an auto build that runs tests on multiple browsers / operating systems. I know that sites like SauceLabs give you easy access to many different browsers and would love to use that, but from what I've gathered, Selenium won't play well with this in benchmarks.
  • In general, it seems that inline tests are written in HTML and there is no support for writing tests in Java (which seems to be the best option for me).

I tried to extend UnitTest and use SauceLabs myself. It seemed to work well, but I ended up hitting a roadblock trying to run the same tests on multiple browsers. I tried using jUnit Parametrized Tests but it didn't work out that good (I kept getting errors in my test classes that have too many constructors).

Are there any best practices for writing System / Selenium tests on Play that:

  • run easily across multiple browsers as part of a continuous integration system ?
  • Are they written in Java and not HTML?

source to share

3 answers

I developed this game! a module that I think might also work for you:


It is still at a very early stage, but it is already operational.

Feel free to develop!



This is certainly possible. However, it is efficient to achieve this without using the Selenium / WebDriver Grid. By default, many browsers will only allow one version to be installed on the system. Although you have control over the launch of the browser, you cannot control which version (or are limited to the version installed).

Using Grid, you can leverage existing infrastructure with the following steps:

  • Install hub node
  • Connect various nodes (machines, virtual machines, etc.) to this hub. These sites host different browsers, and these "capabilities" are registered with the Hub when connected.
  • When the test runs, instead of running it in your local browser, submit the test to the hub, which will try to find the best match for the capability you specified in the nodes that have registered with the Grid. The Grid will do all the necessary sorting of messages back and forth so that you can run tests on the Grid transparently and with the same ease of use as if you were doing it locally.

For more information on the grid see here . While this information is not specifically related to the Play Framework, hopefully it helps.



You don't need to do anything special to run Selenium 2 / WebDriver tests with Play! Framework.

Just write your RemoteWebDriver tests and extend from play.test.UnitTest. These tests will then be executed in Play! TestRunner and obviously the results will be saved to Play! standard way.



All Articles