AllBrowsersPerSuite

traitAllBrowsersPerSuite extends TestSuiteMixin with WebBrowser with Eventually with IntegrationPatience

Trait that uses a shared test approach to enable
you to run the same tests on multiple browsers in a ScalaTest Suite, where each kind of browser is started and stopped
just once for the whole Suite.

Note: the difference between this trait and AllBrowsersPerTest is that
this trait will allow you to write tests that rely on maintaining browser state between the tests. This is a good fit
for integration tests in which each test builds on actions taken by the previous tests.

This trait overrides Suite's withFixture lifecycle method to create a new WebDriver
instance the first time it is needed by each test, and close it the first time it is not needed (thus allowing multiple tests
to share the same browser), and overrides the tags lifecycle method to tag the shared tests so you can
filter them by browser type. This trait's self-type, ServerProvider, will ensure
a TestServer and Application are available to each test. The self-type will require that you mix in either
GuiceOneServerPerSuite, GuiceOneServerPerTest,
ConfiguredServer before you mix in this trait. Your choice among these three
ServerProviders will determine the extent to which a TestServer is shared by multiple tests.

You'll need to place any tests that you want executed by multiple browsers in a sharedTests method. Because all tests in a ScalaTest Suite
must have unique names, you'll need to append the browser name (available from the BrowserInfo passed
to sharedTests) to each test name:

All tests registered via sharedTests will be registered for each desired WebDriver, as specified by the browsers field. When
running, any tests for browser drivers that are unavailable on the current platform will be canceled.
All tests registered under sharedTests will be
tagged automatically if they end with a browser name in square brackets. For example, if a test name ends
with [Firefox], it will be automatically tagged with "org.scalatest.tags.FirefoxBrowser". This will
allow you can include or exclude the shared tests by browser type using ScalaTest's regular tagging feature.

You can use tagging to include or exclude browsers that you sometimes want to test with, but not always. If you
never want to test with a particular browser, you can prevent tests for it from being registered at all
by overriding browsers and excluding its BrowserInfo in the returned Seq. For example, to disable registration of
tests for HtmlUnit, you'd write:

Note that this trait can only be mixed into traits that register tests as functions, as the shared tests technique
is not possible in style traits that declare tests as methods, such as org.scalatest.Spec. Attempting to do so
will become a type error once we release ScalaTest 2.2.0.

Because the shared tests will be tagged according to browser, you can include or exclude tests based
on the browser they use. For example, here's how the output would look if you ran the above test class
with sbt and ask to include only Firefox:

abstract defrunTest(testName: String, args: Args): Status

Implement this method by placing tests you wish to run for multiple browsers. This method
will be called during the initialization of this trait once for each browser whose BrowserInfo
appears in the IndexedSeq referenced from the browsers field.

Make sure you append browser.name to each test declared in sharedTests, to ensure they
all have unique names. Here's an example:

defreloadPage()(implicit driver: WebDriver): Unit

defrunTests(testName: Option[String], args: Args): Status

Invokes super.runTests, ensuring that the currently installed WebDriver (returned
by webDriver) is closed, if necessary.

Invokes super.runTests, ensuring that the currently installed WebDriver (returned
by webDriver) is closed, if necessary. For more information on how this behavior
fits into the big picture, see the documentation for the withFixture method.

testName

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.

args

the Args for this run

returns

a Status object that indicates when all tests and nested suites started by this method have completed, and whether or not a failure occurred.

final defsynchronized[T0](arg0: ⇒ T0): T0

deftags: Map[String, Set[String]]

Automatically tag browser tests with browser tags based on the test name: if a test ends in a browser
name in square brackets, it will be tagged as using that browser.

Automatically tag browser tests with browser tags based on the test name: if a test ends in a browser
name in square brackets, it will be tagged as using that browser. For example, if a test name
ends in [Firefox], it will be tagged with org.scalatest.tags.FirefoxBrowser. The browser tags will be merged with
tags returned from super.tags, so no existing tags will be lost when the browser tags are added.

returns

super.tags with additional browser tags added for any browser-specific tests

defwindowHandle(implicit driver: WebDriver): String

defwindowHandles(implicit driver: WebDriver): Set[String]

Inspects the current test name and if it ends with the name of one of the BrowserInfos
mentioned in the browsersIndexedSeq; if so, and a WebDriver of that type is already
installed and being returned by webDriver, does nothing so that the current test can reuse
the same browser used by the previous test; otherwise, closes the currently installed WebDriver,
if necessary, and creates a new web driver by invoking createWebDriver on
that BrowserInfo and, unless it is an UnavailableDriver, installs it so it will be returned by
webDriver during the test.

Inspects the current test name and if it ends with the name of one of the BrowserInfos
mentioned in the browsersIndexedSeq; if so, and a WebDriver of that type is already
installed and being returned by webDriver, does nothing so that the current test can reuse
the same browser used by the previous test; otherwise, closes the currently installed WebDriver,
if necessary, and creates a new web driver by invoking createWebDriver on
that BrowserInfo and, unless it is an UnavailableDriver, installs it so it will be returned by
webDriver during the test. (If the driver is unavailable on the host platform, the createWebDriver
method will return UnavailableDriver, and this withFixture implementation will cancel the test
automatically.) If the current test name does not end in a browser name, this withFixture method
closes the currently installed WebDriver, if necessary, and installs BrowserInfo.UnneededDriver
as the driver to be returned by webDriver during the test.
If the test is not canceled because of an unavailable driver, this withFixture method invokes
super.withFixture.

Note that unlike AllBrowsersPerTest, this trait's withFixture method
does not ensure that the WebDriver is closed after super.withFixture returns. Instead, this trait will close the
currently installed WebDriver only when it needs to replace the currently installed driver with a new one. This
just-in-time approach to closing WebDrivers is how this trait allows its shared tests to reuse the same browser,
but will at the end of the day, leave the last WebDriver unclosed after withFixture returns for the last time.
This last-used WebDriver will be closed, if necessary, by runTests instead.