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 Details

    • config

      public static ConfigMap config
      Holds values from JSON configuration files.
    • driver

      public static org.openqa.selenium.WebDriver driver
      Web driver instance (chrome, firefox, ...).
    • js

      protected static org.openqa.selenium.JavascriptExecutor js
      JavaScript executor.
    • testSuiteLogCollection

      public static final TestSuiteLogCollection testSuiteLogCollection
      Global log collection that holds all log messages from the tests.
    • testFeatureAnnotation

      protected TestFeature testFeatureAnnotation
      Page object annotation reference.
    • testFeatureLogCollection

      protected TestFeatureLogCollection testFeatureLogCollection
      Log collection for all methods in this class.
    • logCollection

      protected TestScenarioLogCollection logCollection
      Log collection for the current method.
    • NO_MESSAGE

      protected String NO_MESSAGE
      Placeholder for missing messages in assertions.
    • injector

      protected static final com.google.inject.Injector injector
      Guice injector.
  • Constructor Details

    • QtafTestNGContext

      protected QtafTestNGContext()
      Constructor.
  • Method Details

    • initialize

      public QtafTestNGContext initialize()
      Initialize test context.
      Specified by:
      initialize in interface IQtafTestContext
      Returns:
      this
    • load

      protected static <T> T load(IQtafTestContext context, Class<T> c)
      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

      protected <T> T load(Class<T> c)
      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:
      restartDriver in interface IQtafTestContext
    • jsExec

      public void jsExec(String script)
      Execute JavaScript code.
      Parameters:
      script - JavaScript code
    • jsExec

      public void jsExec(String script, Object... args)
      Execute JavaScript code.
      Parameters:
      script - JavaScript code
      args - variables
    • getLogCollection

      public TestScenarioLogCollection getLogCollection()
      Get current log collection.
      Specified by:
      getLogCollection in interface AssertionContext
      Specified by:
      getLogCollection in interface IQtafTestContext
      Returns:
      log collection
    • setLogCollection

      public QtafTestNGContext setLogCollection(TestScenarioLogCollection collection)
      Set the current log collection.
      Specified by:
      setLogCollection in interface IQtafTestContext
      Parameters:
      collection - log collection
      Returns:
      this
    • addLoggerToFieldsRecursively

      public void addLoggerToFieldsRecursively()
      Add logger to all instance fields.
      Specified by:
      addLoggerToFieldsRecursively in interface IQtafTestContext