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 class
Serenity.SerenityConfigurer
static class
Serenity.SessionVariableSetter
-
Constructor Summary
Constructors Constructor Description Serenity()
-
Method Summary
Modifier and Type Method Description static void
clearCurrentSession()
static boolean
currentDriverIsDisabled()
static void
done()
Indicate that the test run using this object is finished, and reports can be generated.static void
done(boolean closeAllDrivers)
static SessionMap<java.lang.Object,java.lang.Object>
getCurrentSession()
static java.lang.String
getCurrentSessionID()
static java.lang.String
getDefaultProjectKey()
static org.openqa.selenium.WebDriver
getDriver()
static org.openqa.selenium.firefox.FirefoxProfile
getFirefoxProfile()
protected static Pages
getPages()
static Pages
getPagesFactory()
static StepFactory
getStepFactory()
static StepListener
getStepListener()
static WebdriverManager
getWebdriverManager()
static boolean
hasASessionVariableCalled(java.lang.Object key)
static void
ignoredStep(java.lang.String reason)
static void
initialize(java.lang.Object testCase)
Initialize Serenity-related fields in the specified object.static void
initializeTestSession()
static Serenity.SerenityConfigurer
initializeWithNoStepListener(java.lang.Object testCase)
Initialize Serenity-related fields in the specified object.static void
initStepListener()
protected static void
injectAnnotatedPagesObjectInto(java.lang.Object testCase)
Instantiates the @ManagedPages-annotated Pages instance using current WebDriver.protected static void
injectDriverInto(java.lang.Object testCase)
Instantiate the @Managed-annotated WebDriver instance with current WebDriver.static void
injectScenarioStepsInto(java.lang.Object testCase)
Instantiates the @ManagedPages-annotated Pages instance using current WebDriver.static void
pendingStep(java.lang.String reason)
static WithTitle
recordReportData()
static void
reportThat(java.lang.String message, Reportable reportableAction)
Perform an arbitrary task and record it as a step in the reports.static <T> T
sessionVariableCalled(java.lang.Object key)
static Serenity.SessionVariableSetter
setSessionVariable(java.lang.Object key)
static boolean
shouldThrowErrorsImmediately()
protected static void
stopUsingMockDriver()
static void
takeScreenshot()
static void
throwExceptionsImmediately()
static void
useFirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile profile)
static WebDriverConfigurer
webdriver()
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
-
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
-
-