Class Serenity


  • public class Serenity
    extends 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 Detail

      • Serenity

        public Serenity()
    • Method Detail

      • initialize

        public static void initialize​(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​(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​(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​(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​(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 String getCurrentSessionID()
      • getDriver

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

        protected static Pages getPages()
      • stopUsingMockDriver

        protected static void stopUsingMockDriver()
      • getStepFactory

        public static StepFactory getStepFactory()
      • getStepListener

        public static StepListener getStepListener()
      • initializeTestSession

        public static void initializeTestSession()
      • pendingStep

        public static void pendingStep​(String reason)
      • ignoredStep

        public static void ignoredStep​(String reason)
      • takeScreenshot

        public static void takeScreenshot()
      • recordReportData

        public static WithTitle recordReportData()
      • getDefaultProjectKey

        public static 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​(Object key)
      • sessionVariableCalled

        public static <T> T sessionVariableCalled​(Object key)
      • clearCurrentSession

        public static void clearCurrentSession()
      • getPagesFactory

        public static Pages getPagesFactory()
      • throwExceptionsImmediately

        public static void throwExceptionsImmediately()
      • shouldThrowErrorsImmediately

        public static boolean shouldThrowErrorsImmediately()
      • reportThat

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