Class Serenity

java.lang.Object
net.serenitybdd.core.Serenity

public class Serenity
extends java.lang.Object
A utility class that provides services to initialize web testing and reporting-related fields in arbitrary objects. It is designed to help integrate Serenity into other testing tools such as Cucumber.
  • Constructor Details

    • Serenity

      public Serenity()
  • Method Details

    • initialize

      public static void initialize​(java.lang.Object testCase)
      Initialize Serenity-related fields in the specified object. This includes managed WebDriver instances,
      Parameters:
      testCase - any object (testcase or other) containing injectable Serenity components
    • initializeWithNoStepListener

      public static Serenity.SerenityConfigurer initializeWithNoStepListener​(java.lang.Object testCase)
      Initialize Serenity-related fields in the specified object. This includes managed WebDriver instances,
      Parameters:
      testCase - any object (testcase or other) containing injectable Serenity components
    • initStepListener

      public static void initStepListener()
    • injectDriverInto

      protected static void injectDriverInto​(java.lang.Object testCase)
      Instantiate the @Managed-annotated WebDriver instance with current WebDriver.
      Parameters:
      testCase - any object (testcase or other) containing injectable Serenity components
    • injectScenarioStepsInto

      public static void injectScenarioStepsInto​(java.lang.Object testCase)
      Instantiates the @ManagedPages-annotated Pages instance using current WebDriver.
      Parameters:
      testCase - any object (testcase or other) containing injectable Serenity components
    • injectAnnotatedPagesObjectInto

      protected static void injectAnnotatedPagesObjectInto​(java.lang.Object testCase)
      Instantiates the @ManagedPages-annotated Pages instance using current WebDriver.
      Parameters:
      testCase - any object (testcase or other) containing injectable Serenity components
    • done

      public static void done()
      Indicate that the test run using this object is finished, and reports can be generated.
    • currentDriverIsDisabled

      public static boolean currentDriverIsDisabled()
    • done

      public static void done​(boolean closeAllDrivers)
    • getCurrentSessionID

      public static java.lang.String getCurrentSessionID()
    • getDriver

      public static org.openqa.selenium.WebDriver getDriver()
    • getPages

      protected static Pages getPages()
    • stopUsingMockDriver

      protected static void stopUsingMockDriver()
    • getWebdriverManager

      public static WebdriverManager getWebdriverManager()
    • getStepFactory

      public static StepFactory getStepFactory()
    • getStepListener

      public static StepListener getStepListener()
    • initializeTestSession

      public static void initializeTestSession()
    • getCurrentSession

      public static SessionMap<java.lang.Object,​java.lang.Object> getCurrentSession()
    • pendingStep

      public static void pendingStep​(java.lang.String reason)
    • ignoredStep

      public static void ignoredStep​(java.lang.String reason)
    • takeScreenshot

      public static void takeScreenshot()
    • recordReportData

      public static WithTitle recordReportData()
    • getDefaultProjectKey

      public static java.lang.String getDefaultProjectKey()
      Returns:
      The current working directory name is used as a default project key if no other key is provided.
    • useFirefoxProfile

      public static void useFirefoxProfile​(org.openqa.selenium.firefox.FirefoxProfile profile)
    • getFirefoxProfile

      public static org.openqa.selenium.firefox.FirefoxProfile getFirefoxProfile()
    • hasASessionVariableCalled

      public static boolean hasASessionVariableCalled​(java.lang.Object key)
    • sessionVariableCalled

      public static <T> T sessionVariableCalled​(java.lang.Object key)
    • setSessionVariable

      public static Serenity.SessionVariableSetter setSessionVariable​(java.lang.Object key)
    • clearCurrentSession

      public static void clearCurrentSession()
    • getPagesFactory

      public static Pages getPagesFactory()
    • throwExceptionsImmediately

      public static void throwExceptionsImmediately()
    • shouldThrowErrorsImmediately

      public static boolean shouldThrowErrorsImmediately()
    • webdriver

      public static WebDriverConfigurer webdriver()
    • reportThat

      public static void reportThat​(java.lang.String message, Reportable reportableAction)
      Perform an arbitrary task and record it as a step in the reports.
      Parameters:
      message -
      reportableAction -