Package net.serenitybdd.core
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.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSerenity.SerenityConfigurerstatic classSerenity.SessionVariableSetter -
Constructor Summary
Constructors Constructor Description Serenity() -
Method Summary
Modifier and Type Method Description static voidclearCurrentSession()static voidclearSessionVariable(java.lang.String key)static booleancurrentDriverIsDisabled()static voiddone()Indicate that the test run using this object is finished, and reports can be generated.static voiddone(boolean closeAllDrivers)static SessionMap<java.lang.Object,java.lang.Object>getCurrentSession()static java.lang.StringgetCurrentSessionID()static java.lang.StringgetDefaultProjectKey()static org.openqa.selenium.WebDrivergetDriver()static org.openqa.selenium.firefox.FirefoxProfilegetFirefoxProfile()protected static PagesgetPages()static PagesgetPagesFactory()static StepFactorygetStepFactory()static StepListenergetStepListener()static WebdriverManagergetWebdriverManager()static booleanhasASessionVariableCalled(java.lang.Object key)static voidignoredStep(java.lang.String reason)static voidinitialize(java.lang.Object testCase)Initialize Serenity-related fields in the specified object.static voidinitializeTestSession()static Serenity.SerenityConfigurerinitializeWithNoStepListener(java.lang.Object testCase)Initialize Serenity-related fields in the specified object.static voidinitStepListener()protected static voidinjectAnnotatedPagesObjectInto(java.lang.Object testCase)Instantiates the @ManagedPages-annotated Pages instance using current WebDriver.protected static voidinjectDriverInto(java.lang.Object testCase)Instantiate the @Managed-annotated WebDriver instance with current WebDriver.static voidinjectScenarioStepsInto(java.lang.Object testCase)Instantiates the @ManagedPages-annotated Pages instance using current WebDriver.static voidpendingStep(java.lang.String reason)static WithTitlerecordReportData()static voidreportThat(java.lang.String message, Reportable reportableAction)Perform an arbitrary task and record it as a step in the reports.static <T> TsessionVariableCalled(java.lang.Object key)static Serenity.SessionVariableSettersetSessionVariable(java.lang.Object key)static booleanshouldThrowErrorsImmediately()protected static voidstopUsingMockDriver()static voidtakeScreenshot()static voidthrowExceptionsImmediately()static voiduseFirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile profile)static WebDriverConfigurerwebdriver()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
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
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
-
stopUsingMockDriver
protected static void stopUsingMockDriver() -
getWebdriverManager
-
getStepFactory
-
getStepListener
-
initializeTestSession
public static void initializeTestSession() -
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
-
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
-
clearSessionVariable
public static void clearSessionVariable(java.lang.String key) -
clearCurrentSession
public static void clearCurrentSession() -
getPagesFactory
-
throwExceptionsImmediately
public static void throwExceptionsImmediately() -
shouldThrowErrorsImmediately
public static boolean shouldThrowErrorsImmediately() -
webdriver
-
reportThat
Perform an arbitrary task and record it as a step in the reports.- Parameters:
message-reportableAction-
-