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.
Places the WebDriver
provided by webDriver
into the ConfigMap
under the key
org.scalatestplus.play.webDriver
to make
it available to nested suites; calls super.run
; and lastly ensures the WebDriver
is stopped after
all tests and nested suites have completed.
Places the WebDriver
provided by webDriver
into the ConfigMap
under the key
org.scalatestplus.play.webDriver
to make
it available to nested suites; calls super.run
; and lastly ensures the WebDriver
is stopped after
all tests and nested suites have completed.
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.
An implicit instance of WebDriver
, created by calling createWebDriver
.
An implicit instance of WebDriver
, created by calling createWebDriver
.
If there is an error when creating the WebDriver
, UnavailableDriver
will be assigned
instead.
Automatically cancels tests with an appropriate error message when the webDriver
field is a UnavailableDriver
,
else calls super.withFixture(test)
Automatically cancels tests with an appropriate error message when the webDriver
field is a UnavailableDriver
,
else calls super.withFixture(test)
Trait that provides a new Selenium
WebDriver
instance per ScalaTestSuite
.This
TestSuiteMixin
trait's overriddenrun
method places a reference to theWebDriver
provided bywebDriver
under the keyorg.scalatestplus.play.webDriver
. This allows any nestedSuite
s to access theSuite
'sWebDriver
as well, most easily by having the nestedSuite
s mix in the ConfiguredBrowser trait. On the status returned bysuper.run
, this trait's overriddenrun
method registers a block of code to close theWebDriver
to be executed when theStatus
completes, and returns the sameStatus
. This ensures theWebDriver
will continue to be available until all nested suites have completed, after which theWebDriver
will be closed. This trait also overridesSuite.withFixture
to cancel tests automatically if the relatedWebDriver
is not available on the host platform.This trait's self-type, ServerProvider, will ensure a
TestServer
andApplication
are 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 threeServerProvider
s will determine the extent to which one or moreTestServer
s 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):
If you have many tests that can share the same
Application
,TestServer
, andWebDriver
, and you don't want to put them all into one test class, you can place them into different "nested"Suite
classes. Create a master suite that extendsOneServerPerSuite
and declares the nestedSuite
s. Annotate the nested suites with@DoNotDiscover
and have them extendConfiguredBrowser
. Here's an example:It is possible to use
OneBrowserPerSuite
to run the same tests in more than one browser. Nevertheless, you should consider the approach taken by AllBrowsersPerSuite and AllBrowsersPerTest instead, as it requires a bit less boilerplate code thanOneBrowserPerSuite
to test in multiple browsers. If you prefer to useOneBrowserPerSuite
, however, simply place your tests in an abstract superclass, then define concrete subclasses for each browser you wish to test against. Here's an example:The concrete subclasses include tag annotations describing the browser used to make it easier to include or exclude browsers in specific runs. This is not strictly necessary since if a browser is not supported on the host platform the tests will be automatically canceled. For example, here's how the output would look if you ran the above tests on a platform that did not support Selenium drivers for Chrome or Internet Explorer using sbt:
For comparison, here is what the output would look like if you just selected tests tagged with
FirefoxBrowser
in sbt: