Looks in args.configMap for a key named "org.scalatestplus.play.webDriver" whose value is a WebDriver,
and if it exists, sets the WebDriver as
the value that will be returned from the webDriver method, then calls
super.run.
Looks in args.configMap for a key named "org.scalatestplus.play.webDriver" whose value is a WebDriver,
and if it exists, sets the WebDriver as
the value that will be returned from the webDriver method, then calls
super.run.
If no key matches "org.scalatestplus.play.webDriver" in args.configMap,
or the associated value is not a WebDriver, throws IllegalArgumentException.
an optional name of one test to run. If None, all relevant tests should be run.
I.e., None acts like a wildcard that means run all relevant tests in this Suite.
the Args for this run
a Status object that indicates when all tests and nested suites started by this method have completed, and whether or not a failure occurred.
java.lang.IllegalArgumentException if the WebDriver does not appear in args.configMap under the expected key
The "configured" Selenium WebDriver, passed into run via the ConfigMap.
The "configured" Selenium WebDriver, passed into run via the ConfigMap.
the configured port number
Trait that provides a configured
Application, server port number, and SeleniumWebDriverto the suite into which it is mixed.The purpose of this trait is to allow nested suites of an enclosing suite that extends OneBrowserPerSuite to make use of the
WebDriverprovided byOneBrowserPerSuite. TraitOneBrowserPerSuitewill ensure theWebDriveris placed in theConfigMapunder the keyorg.scalatestplus.play.webDriverbefore nested suites are invoked. This information represents the "configured browser" that is passed from the enclosing suite to the nested suites. TraitConfiguredBrowserextracts this information from from theConfigMapand makes theWebDriveravailable implicitly from thewebDrivermethod.This trait's self-type, ServerProvider, will ensure a
TestServerandApplicationare available to each test. The self-type will require that you mix in either GuiceOneServerPerSuite, OneServerPerTest, ConfiguredServer before you mix in this trait. Your choice among these threeServerProviders will determine the extent to which one or moreTestServers are shared by multiple tests.To prevent discovery of nested suites you can annotate them with
@DoNotDiscover. Here's an example taken from the documentation for trait OneBrowserPerSuite:package org.scalatestplus.play.examples.onebrowserpersuite import play.api.test.Helpers import org.scalatest.tags.FirefoxBrowser import org.scalatestplus.play._ import play.api.{Play, Application} import play.api.inject.guice._ import play.api.routing._ @FirefoxBrowser class ExampleSpec extends PlaySpec with OneServerPerSuite with OneBrowserPerSuite with FirefoxFactory { // Override fakeApplication() if you need a Application with other than non-default parameters. def fakeApplication(): Application = new GuiceApplicationBuilder() .configure("foo" -> "bar", "ehcacheplugin" -> "disabled") .router(Router.from(TestRoute)) .build() "The OneBrowserPerSuite trait" must { "provide an Application" in { app.configuration.getString("ehcacheplugin") mustBe Some("disabled") } "make the Application available implicitly" in { def getConfig(key: String)(implicit app: Application) = app.configuration.getString(key) getConfig("ehcacheplugin") mustBe Some("disabled") } "start the Application" in { Play.maybeApplication mustBe Some(app) } "provide the port number" in { port mustBe Helpers.testServerPort } "provide an actual running server" in { import java.net._ val url = new URL("http://localhost:" + port + "/boum") val con = url.openConnection().asInstanceOf[HttpURLConnection] try con.getResponseCode mustBe 404 finally con.disconnect() } "provide a web driver" in { go to ("http://localhost:" + port + "/testing") pageTitle mustBe "Test Page" click on find(name("b")).value eventually { pageTitle mustBe "scalatest" } } } }