Package de.qytera.qtaf.testng.context
Class QtafTestNGContext
java.lang.Object
de.qytera.qtaf.testng.context.QtafTestNGContext
- All Implemented Interfaces:
IQtafTestContext,AssertionContext
- Direct Known Subclasses:
QtafCucumberHooks
@Guice(modules=QtafModule.class)
public abstract class QtafTestNGContext
extends Object
implements IQtafTestContext, AssertionContext
Test context works as a factory class and state manager for test classes.
It provides information about the current test class like information about
annotations and holds objects needed during test executing (i.e. loggers, etc).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic ConfigMapHolds values from JSON configuration files.static org.openqa.selenium.WebDriverWeb driver instance (chrome, firefox, ...).protected static final com.google.inject.InjectorGuice injector.protected static org.openqa.selenium.JavascriptExecutorJavaScript executor.protected TestScenarioLogCollectionLog collection for the current method.protected StringPlaceholder for missing messages in assertions.protected TestFeaturePage object annotation reference.protected TestFeatureLogCollectionLog collection for all methods in this class.static final TestSuiteLogCollectionGlobal log collection that holds all log messages from the tests. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd logger to all instance fields.Get current log collection.protected voidCall the Selenium PageFactory initElements method on this instance.Initialize test context.voidExecute JavaScript code.voidExecute JavaScript code.protected static <T> Tload(IQtafTestContext context, Class<T> c) Load class instance.protected <T> TLoad class instance.voidRestart browser.setLogCollection(TestScenarioLogCollection collection) Set the current log collection.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.qytera.qtaf.testng.context.AssertionContext
assertEquals, assertEquals, assertEquals, assertEqualsDeep, assertEqualsDeep, assertEqualsDeep, assertEqualsDeep, assertEqualsDeep, assertEqualsDeep, assertEqualsNoOrder, assertEqualsNoOrder, assertEqualsNoOrder, assertFalse, assertFalse, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEqualsDeep, assertNotEqualsDeep, assertNotEqualsDeep, assertNotEqualsDeep, assertNotEqualsDeep, assertNotEqualsDeep, assertNotNull, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNotSame, assertNull, assertNull, assertNull, assertSame, assertSame, assertSame, assertTrue, assertTrue, buildAssertionLogMessage, getNoMessageString, handleAssertCondition, handleAssertCondition, handleAssertCondition, handleAssertEquals, handleAssertEqualsDeep, handleAssertEqualsNoOrder, handleAssertFalse, handleAssertNotEquals, handleAssertNotEqualsDeep, handleAssertNotNull, handleAssertNotSame, handleAssertNull, handleAssertSame, handleAssertTrue
-
Field Details
-
config
Holds values from JSON configuration files. -
driver
public static org.openqa.selenium.WebDriver driverWeb driver instance (chrome, firefox, ...). -
js
protected static org.openqa.selenium.JavascriptExecutor jsJavaScript executor. -
testSuiteLogCollection
Global log collection that holds all log messages from the tests. -
testFeatureAnnotation
Page object annotation reference. -
testFeatureLogCollection
Log collection for all methods in this class. -
logCollection
Log collection for the current method. -
NO_MESSAGE
Placeholder for missing messages in assertions. -
injector
protected static final com.google.inject.Injector injectorGuice injector.
-
-
Constructor Details
-
QtafTestNGContext
protected QtafTestNGContext()Constructor.
-
-
Method Details
-
initialize
Initialize test context.- Specified by:
initializein interfaceIQtafTestContext- Returns:
- this
-
load
Load class instance.- Type Parameters:
T- the class type- Parameters:
context- The current test context (pass 'this' for this argument)c- The desired class you want to create an instance of- Returns:
- Instance of the desired class
-
load
Load class instance.- Type Parameters:
T- the class type- Parameters:
c- The desired class you want to create an instance of- Returns:
- Instance of the desired class
-
initElements
protected void initElements()Call the Selenium PageFactory initElements method on this instance. -
restartDriver
public void restartDriver()Restart browser.- Specified by:
restartDriverin interfaceIQtafTestContext
-
jsExec
Execute JavaScript code.- Parameters:
script- JavaScript code
-
jsExec
Execute JavaScript code.- Parameters:
script- JavaScript codeargs- variables
-
getLogCollection
Get current log collection.- Specified by:
getLogCollectionin interfaceAssertionContext- Specified by:
getLogCollectionin interfaceIQtafTestContext- Returns:
- log collection
-
setLogCollection
Set the current log collection.- Specified by:
setLogCollectionin interfaceIQtafTestContext- Parameters:
collection- log collection- Returns:
- this
-
addLoggerToFieldsRecursively
public void addLoggerToFieldsRecursively()Add logger to all instance fields.- Specified by:
addLoggerToFieldsRecursivelyin interfaceIQtafTestContext
-