Creates a new instance of a valid Selenium WebDriver, or if a driver is unavailable on the host platform,
returns a BrowserFactory.UnavailableDriver that includes
the exception that indicated the driver was not supported on the host platform and an appropriate
error message.
Creates a new instance of a valid Selenium WebDriver, or if a driver is unavailable on the host platform,
returns a BrowserFactory.UnavailableDriver that includes
the exception that indicated the driver was not supported on the host platform and an appropriate
error message.
an new instance of a Selenium WebDriver, or a BrowserFactory.UnavailableDriver
if the desired WebDriver is not available on the host platform.
Implicit method to get the WebDriver for the current test.
Creates a new instance of WebDriver before
running each test, ensuring it is closed after the test completes.
Creates a new instance of WebDriver before
running each test, ensuring it is closed after the test completes.
If an error occurs when attempting to creat the WebDriver, BrowserFactory.UnavailableDriver
will be used instead and all tests will be canceled automatically.
the no-arg test function to run with a fixture
the Outcome of the test execution
Trait that provides a new Selenium
WebDriverinstance for each test executed in a ScalaTestSuite.This trait overrides ScalaTest's
withFixturemethod to create a newWebDriverinstance before each test, and ensure it is closed after the test has completed. TheWebDriveris available (implicitly) from methodwebDriver.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.Here's an example that shows demonstrates of the services provided by this trait. Note that to use this trait, you must mix in one of the driver factories (this example mixes in FirefoxFactory):
package org.scalatestplus.play.examples.onebrowserpertest import play.api.test._ import org.scalatest._ 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 OneServerPerTest with OneBrowserPerTest with FirefoxFactory { // Override newAppForTest if you need an Application with other than non-default parameters. override def newAppForTest(testData: TestData): Application = new GuiceApplicationBuilder() .configure(Map("ehcacheplugin" -> "disabled")) .router(Router.from(TestRoute)) .build() "The OneBrowserPerTest 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 Helpers._ 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" } } } }