Class SmartCucumberScenarioContext


  • public class SmartCucumberScenarioContext
    extends Object
    Generic interface for cucumber scenario context.
    Author:
    Madhav Krishna
    • Field Detail

      • scenario

        protected io.cucumber.java.Scenario scenario
      • isUiScenario

        protected boolean isUiScenario
      • screenCaptureFailedStatus

        protected String screenCaptureFailedStatus
      • activeAppName

        protected String activeAppName
    • Constructor Detail

      • SmartCucumberScenarioContext

        public SmartCucumberScenarioContext()
    • Method Detail

      • connectOrSwitch

        public AbstractAppConnector connectOrSwitch​(String appName)
        Connect or switch to application.
        Parameters:
        appName -
      • connectOrSwitch

        public SmartAppDriver connectOrSwitch​(String appName,
                                              String userProfileName)
        Connect or switch to specified application and set the user profile.
        Parameters:
        appName -
        userProfileName -
        Returns:
      • setActiveUserProfile

        public SmartAppDriver setActiveUserProfile​(String appName,
                                                   String userProfileName)
        Sets the active user profile on the application. If application is not connected then it will connect to application first and then set the user profile.
        Parameters:
        appName -
        userProfileName -
        Returns:
      • setActiveUserProfileOnActiveApp

        public SmartAppDriver setActiveUserProfileOnActiveApp​(String userProfileName)
      • getActiveUserProfileNameOfActiveApp

        public String getActiveUserProfileNameOfActiveApp()
      • getActiveUserProfileName

        public String getActiveUserProfileName​(String appName)
      • overrideDriverProps

        public void overrideDriverProps​(String applicationName,
                                        String browserType,
                                        String propsAsJson)
      • getOverriddenDriverProps

        public com.jayway.jsonpath.DocumentContext getOverriddenDriverProps​(String applicationName,
                                                                            String browserType)
      • captureScreenshot

        public void captureScreenshot()
      • captureScreenshot

        public String captureScreenshot​(String fileNameHint)
      • captureScreenshotWithScenarioStatus

        public void captureScreenshotWithScenarioStatus​(String status)
      • captureScreenshotOfApp

        public void captureScreenshotOfApp​(String appName)
      • captureScreenshotOfAppWithScenarioStatus

        public void captureScreenshotOfAppWithScenarioStatus​(String appName,
                                                             String status)
      • switchToDefaultContent

        public void switchToDefaultContent()
        Switches all apps to default contents.
      • switchToDefaultContent

        public void switchToDefaultContent​(String appName)
        Switches the specified app to default content.
        Parameters:
        appName -
      • switchToWindow

        public void switchToWindow​(String nameOrHandle)
      • switchToWindow

        public void switchToWindow​(String appName,
                                   String nameOrHandle)
      • switchToFrame

        public void switchToFrame​(String nameOrId)
      • switchToFrame

        public void switchToFrame​(UIObject pageElement)
      • switchToFrame

        public void switchToFrame​(int index)
      • switchToNewWindow

        public void switchToNewWindow​(org.openqa.selenium.WindowType typeHint)
        It creates the new window and switches the focus on it for future commands.
        Parameters:
        typeHint -
      • closeAllChildWindows

        public void closeAllChildWindows()
      • close

        public void close()
      • close

        public void close​(boolean captureScreenshot)
      • getScenario

        public io.cucumber.java.Scenario getScenario()
      • setScenario

        public void setScenario​(io.cucumber.java.Scenario scenario)
      • getActiveAppName

        public String getActiveAppName()
      • getActiveAppConfig

        public AppConfig getActiveAppConfig()
      • log

        public void log​(String message)
      • addParamValue

        public void addParamValue​(String paramName,
                                  Object value)
      • getParamValue

        public Object getParamValue​(String paramName)
        This method returns param value. If does not exist then returns as null.
        Parameters:
        paramName -
        Returns:
      • getParamValueAsString

        public String getParamValueAsString​(String paramName)
      • getParamValueAsInteger

        public Integer getParamValueAsInteger​(String paramName)
      • getParamValueAsLong

        public Long getParamValueAsLong​(String paramName)
      • getParamValueAsDouble

        public Double getParamValueAsDouble​(String paramName)
      • getParamValueAsBoolean

        public Boolean getParamValueAsBoolean​(String paramName)
      • getMultiValueParamValueAsString

        public String getMultiValueParamValueAsString​(String paramName,
                                                      String delimitter,
                                                      String valueEnclosingChars)
        MultiValue params are like Array, List, Set
        Parameters:
        paramName -
        delimitter - - could be , or any string, if null then it will use default as ,
        valueEnclosingChars - like ' or " or empty/null (denotes no enclosing)
        Returns:
      • getEntriesForParamsEndsWithText

        public Map<String,​Object> getEntriesForParamsEndsWithText​(String text)
      • getEntriesForParamsStartsWithText

        public Map<String,​Object> getEntriesForParamsStartsWithText​(String text)
      • getParamValueNullAsParamName

        public Object getParamValueNullAsParamName​(String paramName)
        This method returns param value. If does not exist then returns paramName as value.
        Parameters:
        paramName -
        Returns:
      • removeParam

        public void removeParam​(String paramName)
      • isUiScenario

        public boolean isUiScenario()
      • setCondition

        public void setCondition​(String conditionName,
                                 Boolean value)
      • isConditionSet

        public boolean isConditionSet​(String conditionName)
      • unsetCondition

        public void unsetCondition​(String conditionName)
      • unsetAllConditions

        public void unsetAllConditions()
      • isLastConditionSetToTrue

        public boolean isLastConditionSetToTrue()
      • getLastConditionName

        public String getLastConditionName()
      • applyParamsValueOnText

        public String applyParamsValueOnText​(String text)
        It will apply all params value to the text. It will convert param value to string then apply. Apply order: 1. First applies the DefaultSmartCache params. 2. Then applies the scenarioContext params.
        Parameters:
        text -
        Returns:
        the updated text
      • waitForSeconds

        public void waitForSeconds​(int seconds)