public abstract class SAFSPlus
extends java.lang.Object
This class will provide a general JAVA API to access the SAFS keywords. NOTE 1: Auto-evaluated expression. SAFSPlus has the ability to process string as an expression. For example, "36+9", "25*6" will be calculated as "45", "150" automatically; "^" is considered as the leading char of a variable, hence "^var" will be considered as a variable "var", if variable "var" exists, then "^var" will be replaced by its value, otherwise replaced by empty string "". This ability is very useful for user, but sometimes it will cause UN-EXPECTED result during calling SAFSPlus's API. For example, user wants to input a string "this is a combined-word" to an EditBox, the EditBox will receive "this is a 0", which is not an expected result; user wants to select all text of an EditBox, he uses "Ctrl+a" by calling SAFSPlus.TypeKeys("^a") and he finds that doesn't work (the reason is that "^a" is parsed to "", because "^a" is considered as variable). To avoid the problem caused by arithmetic char "+ - * /", we can call API Misc.Expressions(false) to turn off the parse of an expression.For more info on command-line options, seeMisc.Expressions(false); SAFSPlus.TypeChars("this is a combined-word"); ComboBox.CaptureItemsToFile(combobox, "ComboBoxData.txt", "UTF-8");
To avoid the problem caused by caret ^ or by arithmetic char "+ - * /", we can double-quote the parameterSAFSPlus.TypeKeys("\"^p\"")); SAFSPlus.TypeKeys(quote("^p")));//quote is a static method provided by SAFSPlus SAFSPlus.TypeChars(quote("this is a combined-word"));
NOTE 2: File path deducing. In SAFSPlus, there are some APIs like CaptureXXXToFile, VerifyXXXToFile, they require file-path as parameter. As our doc is not very clear, user may confuse with the file-path parameter. Let's make it clear: There are 2 types of file, the test-file and bench-file. User can provide absolute or relative file-path for them. If it is absolute, there is not confusion. If it is relative, we will combine it with a base-directory to form an absolute file. The base-directory depends on the type of file (test or bench): if it is test-file, the base-directory will be the test-directory,/Actuals/ if it is bench-file, the base-directory will be the bench-directory, /Benchmarks/ After the combination, the combined-file-name will be tested, if it is not valid, the project-directory will be used as base-directory. NOTE 3: DDVariable To use DDVariable ability, PLEASE remember to turn on the Expression by Misc.Expressions(true); The DDVariable is a variable reference, it can be expressed by a leading symbol ^ and the "variable name". For example: ^user.name ^user.password DDVariable can be used along with an assignment or by itself, example as following: Misc.Expressions(true); //set value "UserA" to variable "user.name", set "Password1" to variable "user.password" Misc.SetVariableValues("^user.name=UserA","^user.password=Password1"); //input the value of variable "user.name" Component.InputCharacters(Map.AUT.UserInput, "^user.name"); //input the value of variable "user.password" Component.InputCharacters(Map.AUT.PassWord, "^user.password");
NOTE 4: a known issue about clicking on wrong item Please to TURN OFF the browser's status bar.
main(String[])
.Modifier and Type | Class and Description |
---|---|
static class |
SAFSPlus.Assert
A set of assertions methods for tests.
|
static class |
SAFSPlus.CheckBox
Wrapper class providing APIs to handle CheckBox keywords, like Check, UnCheck.
|
static class |
SAFSPlus.ComboBox
Wrapper class providing APIs to handle ComboBox keywords, like Select, ShowList, SetTextValue etc.
|
static class |
SAFSPlus.Component
Wrapper class providing APIs to handle
GenericMasterFunctions Reference and
GenericObjectFunctions Reference, like VerifyProperty, IsPropertyExist etc.
|
static class |
SAFSPlus.Counters
Wrapper class providing APIs to handle DriverCounter keywords, like StartTestSuite, StartCounter, LogCounterInfo etc.
It also provides: some convenient APIs, like SAFSPlus.Counters.PrintTestCaseSummary(String) , SAFSPlus.Counters.PrintTestSuiteSummary(String) etc. |
static class |
SAFSPlus.DriverCommand
Wrapper class providing APIs to handle Driver keywords, like StartWebBrowser, UseWebBrowser, SetPosition etc.
|
static class |
SAFSPlus.EditBox
Wrapper class providing APIs to handle EditBox keywords, like SetTextValue, SetTextCharacters etc.
|
static class |
SAFSPlus.Files
Wrapper class providing APIs to handle File keywords, like OpenFile, ReadFileLine etc.
|
static class |
SAFSPlus.ListView
Wrapper class providing APIs to handle ListView keywords, like ClickIndex, VerifyListContains etc.
|
static class |
SAFSPlus.Logging
Wrapper class providing APIs to handle Logging keywords, like LogMessage, LogTestWarning etc.
|
static class |
SAFSPlus.Menu
Wrapper class providing APIs to handle MenuBar/Menu keywords, like SelectMenuItem, VerifyMenuItemContains etc.
|
static class |
SAFSPlus.Misc
Class for miscellaneous Driver Commands.
This is a sub-class of DriverCommand and it provides more convenient wrapper APIs. |
static class |
SAFSPlus.Rest
Wrapper class providing APIs to handle
TIDRestFunctions Reference and
DriverRestCommands Reference, like RestGetBinary, RestStoreResponse etc.
|
static class |
SAFSPlus.ScrollBar
Wrapper class providing APIs to handle ScrollBar keywords, like OneDown, PageDown, PageUp etc.
|
static class |
SAFSPlus.Strings
Wrapper class providing APIs to handle String keywords, like Compare, GetMultiDelimitedField etc.
|
static class |
SAFSPlus.TabControl
Wrapper class providing APIs to handle TabControl keywords, like ClickTab, SelectTabIndex etc.
|
static class |
SAFSPlus.Tree
Wrapper class providing APIs to handle Tree keywords, like ClickTextNode, ExpandTextNode etc.
|
static class |
SAFSPlus.Window
Wrapper class providing APIs to handle Window keywords, like Maximize, Minimize, SetPosition etc.
|
Modifier and Type | Field and Description |
---|---|
protected static boolean |
_autorun
If true at runtime we will execute Runner.autorun() instead of runTest().
|
protected static boolean |
_autorunClassProvided
If true at runtime means user has provided the "automatic run test class", we will not deduce it.
|
protected static boolean |
_injectDataAwareness
Set true if a 3rd party injection should still injectRuntimeDataAwareness classes into Maps, etc.
|
protected static boolean |
_isInjected
Set to true if we are injecting SAFS/Se+ into a 3rd party process.
|
protected static boolean |
_isSPC
Set to true if we are running a Process Container type of process that does NOT
lookup a test to execute.
|
protected static java.lang.String |
_junit
junit class to execute if we are running a junit test instead of the traditional runTest method.
|
protected static boolean |
allowExit |
static java.lang.String |
ARG_AUTORUN
"-autorun"
command-line argument to enable Dependency Injection, AutoConfig, and AutoExecution. |
static java.lang.String |
ARG_AUTORUN_CLASS
"-autorunclass", the parameter to indicate the class name to run test automatically.
Only when parameter ARG_AUTORUN is present, this parameter will take effect.Example, "-autorunclass autorun.full.classname". |
static java.lang.String |
ARG_JUNIT
"-junit:"
command-line argument to invoke a JUnit class instead of a SAFSPlus subclass. Example: -junit:com.sas.spock.tests.SpockExperiment |
static java.lang.String |
ARG_SAFSVAR
"-safsvar:"
command-line argument syntax: -safsvar:name=value |
protected static AbstractRunner |
DefaultRunner
Keep the reference to the default Runner.
|
protected static int |
exitCode
exitCode is used to exit JVM from the method main(). |
protected static boolean |
normalizeTextForInput |
static TestRecordHelper |
prevResults
Holds the TestRecordHelper object containing detailed information and results for
the last action or command executed.
|
static java.lang.String |
PRODUCT_DESCRIPTION
'The driver equipped with rich APIs to run test script in Java.'
|
static java.lang.String |
PRODUCT_NAME
'SAFSPlus'
|
static java.lang.String |
PRODUCT_VERSION
'1.0'
|
static java.lang.String |
RELATIVE_TO_PARENT |
static java.lang.String |
RELATIVE_TO_SCREEN |
protected static AbstractRunner |
Runner
The Runner object providing access to the underlying Engines, like RFT, TestComplete, Selenium etc.
|
protected static org.springframework.context.ApplicationContext |
springApplicationContext
The spring application context from where we can get the beans.
|
Constructor and Description |
---|
SAFSPlus() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
_getMappedValue(java.lang.String mapid,
java.lang.String section,
java.lang.String item) |
static java.lang.String |
_getVariable(java.lang.String varname) |
protected static void |
_processArgs(java.lang.String[] args) |
protected static java.lang.String[] |
_resolveDDVariables(java.lang.String parameter,
java.lang.String... optionals)
Resolve parameters as DDVariable ONLY when
SAFSPlus.Misc.isExpressionsOn() is false.If SAFSPlus.Misc.isExpressionsOn() is true, we simply call combineParams(String[], String...) to put parameters into an array, later org.safs.model.tools.AbstractDriver will evaluate them. |
static void |
_setVariable(java.lang.String varname,
java.lang.String value) |
static void |
AbortTest(java.lang.String reason)
Abort running test flow.
|
protected static boolean |
action(Component component,
java.lang.String command,
java.lang.String... params)
Execute a 'component action' on the component.
|
protected static boolean |
actionGUILess(java.lang.String command,
java.lang.String... params)
Execute a 'component action' without a component.
|
protected void |
autorun(java.lang.String[] args)
This is the method to start the automatic test.
|
static boolean |
back()
Navigate to the previous page.
|
protected static java.lang.String[] |
combineParams(java.lang.String[] extraParams,
java.lang.String... preParams)
Combine the required parameters and optional parameters and return them as an array.
|
protected static boolean |
command(java.lang.String command,
java.lang.String... params)
Execute a driver command.
|
static void |
debug(java.lang.String message) |
static void |
error(java.lang.String message) |
static boolean |
forward()
Navigate to the next page.
|
static boolean |
getAllowExit() |
static int |
getExitCode() |
static AbstractRunner |
getRunner() |
static java.lang.String |
GetVariableValue(java.lang.String variableName)
Convenience routine to retrieve the value of a SAFS Variable stored in SAFSVARS.
|
static DriverInterface |
iDriver() |
static void |
main(java.lang.String[] args)
Internal framework use only.
|
protected static java.lang.String |
normalizeTextForInput(java.lang.String text)
Normalize text string for input.
|
static java.lang.String |
quote(java.lang.String parameter)
Add double-quote around a string value.
|
protected static java.lang.String |
quotePath(java.lang.String path) |
protected static java.lang.String[] |
replaceSeparator(java.lang.String... params)
Sometimes the parameter (like coordination) will contain separator, but if this one is
the same as 'test-step-separator', then that parameter will not be correctly parsed, we need to replace it by a different one. To replace the possible conflicted separator in parameters. |
abstract void |
runTest()
INTERNAL USE ONLY.
|
static void |
setAllowExit(boolean allow) |
static void |
setExitCode(int rcCode) |
static void |
setLeveledTest(boolean leveledTest)
Set this field to true if user defines the leveled-test with the following methods.
|
static boolean |
setNormalizeTextForInput(boolean bool)
Please call this method to set a true value, if the leading/ending "whitespace"
needs to be kept when calling API (handles text input), such as
SAFSPlus.Component.TypeKeys(String)
SAFSPlus.Component.TypeChars(String)
SAFSPlus.Component.InputKeys(org.safs.model.Component, String)
SAFSPlus.Component.InputCharacters(org.safs.model.Component, String)
SAFSPlus.EditBox.SetTextCharacters(org.safs.model.Component, String)
SAFSPlus.EditBox.SetTextValue(org.safs.model.Component, String)
SAFSPlus.EditBox.SetUnverifiedTextCharacters(org.safs.model.Component, String)
SAFSPlus.EditBox.SetUnverifiedTextValue(org.safs.model.Component, String)
|
protected void |
setRunner(AbstractRunner Runner)
To get the SAFSPlus work correctly for the sub-class (Ex.
|
static boolean |
SetVariableValue(java.lang.String variableName,
java.lang.String variableValue)
Convenience routine to set the value of a SAFS Variable stored in SAFSVARS.
The act of logging success or failure will change prevResults. |
protected static boolean |
testStatusCode(java.lang.String command,
TestRecordHelper testRecord)
Check the status code of the TestRecord.
|
protected static AbstractRunner Runner
public static final java.lang.String PRODUCT_NAME
public static final java.lang.String PRODUCT_VERSION
public static final java.lang.String PRODUCT_DESCRIPTION
protected static org.springframework.context.ApplicationContext springApplicationContext
protected static AbstractRunner DefaultRunner
resetRunner()
public static final java.lang.String ARG_AUTORUN
public static final java.lang.String ARG_JUNIT
public static final java.lang.String ARG_AUTORUN_CLASS
ARG_AUTORUN
is present, this parameter will take effect.public static final java.lang.String ARG_SAFSVAR
public static final java.lang.String RELATIVE_TO_SCREEN
public static final java.lang.String RELATIVE_TO_PARENT
public static TestRecordHelper prevResults
protected static boolean _autorun
runTest()
,
AbstractRunner.autorun(String[])
protected static boolean _autorunClassProvided
protected static boolean _isSPC
protected static boolean _isInjected
protected static boolean _injectDataAwareness
protected static java.lang.String _junit
protected static boolean normalizeTextForInput
protected static int exitCode
exitCode
is used to exit JVM from the method main(). The default value is 0. protected static boolean allowExit
public static AbstractRunner getRunner()
protected void setRunner(AbstractRunner Runner)
Runner
- public abstract void runTest() throws java.lang.Throwable
Start writing tests in this required method in your subclass. This must be an "instance" method because subclasses cannot Override static superclass methods.
java.lang.Throwable
public static DriverInterface iDriver()
public static void _setVariable(java.lang.String varname, java.lang.String value)
public static java.lang.String _getVariable(java.lang.String varname)
public static java.lang.String _getMappedValue(java.lang.String mapid, java.lang.String section, java.lang.String item)
public static boolean SetVariableValue(java.lang.String variableName, java.lang.String variableValue)
variableName
- -- Name of variable to set.variableValue
- -- value to store in variableName.prevResults
,
SAFSPlus.DriverCommand.SetVariableValues(String, String...)
,
SAFSPlus.DriverCommand.SetVariableValueEx(String, String)
public static boolean setNormalizeTextForInput(boolean bool)
SAFSPlus.Component.TypeKeys(String)
SAFSPlus.Component.TypeChars(String)
SAFSPlus.Component.InputKeys(org.safs.model.Component, String)
SAFSPlus.Component.InputCharacters(org.safs.model.Component, String)
SAFSPlus.EditBox.SetTextCharacters(org.safs.model.Component, String)
SAFSPlus.EditBox.SetTextValue(org.safs.model.Component, String)
SAFSPlus.EditBox.SetUnverifiedTextCharacters(org.safs.model.Component, String)
SAFSPlus.EditBox.SetUnverifiedTextValue(org.safs.model.Component, String)
bool
- boolean, if normalization is needed for text when inputingnormalizeTextForInput(String)
protected static java.lang.String normalizeTextForInput(java.lang.String text)
In SAFSPlus/SeleniumPlus, if the parameter contains leading/ending spaces, it will be trimmed. For most methods, it is expected; But for InputKeys, InputChars, TypeKeys and TypeChars, this implicit action is NOT expected. If user wants to input a space, he uses Component.TypeChars(" "); but the parameter is trimmed and he will not get the result he expects. If user wants to type a short-cut "Ctrl+Space", he uses Component.TypeKeys("^ "); but the parameter is trimmed and he will not get the result he expects and even worse the "Ctrl key" will not be released! At this situation, we use this method to double-quote the parameter to avoid these unexpected behaviors.
text
- String, the text string to normalize.SAFSPlus.Component.TypeKeys(String)
,
SAFSPlus.Component.TypeChars(String)
,
SAFSPlus.Component.InputKeys(org.safs.model.Component, String)
,
SAFSPlus.Component.InputCharacters(org.safs.model.Component, String)
,
SAFSPlus.EditBox.SetTextCharacters(org.safs.model.Component, String)
,
SAFSPlus.EditBox.SetTextValue(org.safs.model.Component, String)
,
SAFSPlus.EditBox.SetUnverifiedTextCharacters(org.safs.model.Component, String)
,
SAFSPlus.EditBox.SetUnverifiedTextValue(org.safs.model.Component, String)
public static java.lang.String GetVariableValue(java.lang.String variableName)
variableName
- Does not change prevResults.
prevResults
public static void AbortTest(java.lang.String reason) throws java.lang.Throwable
reason
- will be prepended to the detailed abort information.java.lang.Throwable
prevResults
AbortTest("reason for abort");
Clears prevResults TestRecordHelper to null.public static boolean back()
public static boolean forward()
public static java.lang.String quote(java.lang.String parameter)
parameter
- String, the string to be double-quoted.protected static java.lang.String quotePath(java.lang.String path)
protected static java.lang.String[] replaceSeparator(java.lang.String... params)
protected static java.lang.String[] combineParams(java.lang.String[] extraParams, java.lang.String... preParams)
extraParams
- String[], the optional parameters; can be null, if there is no optional parameters.preParams
- String ..., the required parametersprotected static java.lang.String[] _resolveDDVariables(java.lang.String parameter, java.lang.String... optionals) throws SeleniumPlusException
SAFSPlus.Misc.isExpressionsOn()
is false.SAFSPlus.Misc.isExpressionsOn()
is true, we simply call combineParams(String[], String...)
parameter
- String, the first parameteroptionals
- String[], the optional parametersSeleniumPlusException
Misc#Expressions(boolean)}
,
Misc#isExpressionsOn()}
,
combineParams(String[], String...)
,
SAFSPlus.DriverCommand.SetVariableValueEx(String, String)
,
SAFSPlus.DriverCommand.SetVariableValues(String, String...)
protected static boolean testStatusCode(java.lang.String command, TestRecordHelper testRecord)
command
- String, the command that was executed.testRecord
- TestRecordHelper, the result of the execution.StatusCodes.NO_SCRIPT_FAILURE
protected static boolean actionGUILess(java.lang.String command, java.lang.String... params) throws SAFSRuntimeException
command
- String, the name of the 'component action' to execute.params
- String[], the parameters for the 'component action'.Sets prevResults TestRecordHelper to the results received or null if an error occurred.
SAFSRuntimeException
- if detecting a user-initiated shutdown/abort requestprevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
,
action(org.safs.model.Component, String, String...)
protected static boolean action(Component component, java.lang.String command, java.lang.String... params) throws SAFSRuntimeException
component
- Component, the component to execution some action on.command
- String, the name of the 'component action' to execute.params
- String[], the parameters for the 'component action'.Sets prevResults TestRecordHelper to the results received or null if an error occurred.
SAFSRuntimeException
- if detecting a user-initiated shutdown/abort requestprevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
protected static boolean command(java.lang.String command, java.lang.String... params) throws SAFSRuntimeException
command
- String, the name of the driver command to execute.params
- String[], the parameters for the driver command.Sets prevResults TestRecordHelper to the results received or null if an error occurred.
SAFSRuntimeException
- if detecting a user-initiated shutdown/abort requestprevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
protected void autorun(java.lang.String[] args) throws java.lang.Throwable
protected void autorun(String[] args) throws Throwable{ String[] adjustedArgs = combineParams(args, SAFSPlus.ARG_AUTORUN_CLASS, "your.auto.run.classname"); super.autorun(adjustedArgs); }
args
- passed in from command-line Java-- the primordial main(String[] args)java.lang.Throwable
protected static void _processArgs(java.lang.String[] args)
public static void setExitCode(int rcCode)
public static int getExitCode()
public static void setAllowExit(boolean allow)
public static boolean getAllowExit()
public static void debug(java.lang.String message)
public static void error(java.lang.String message)
public static void main(java.lang.String[] args)
Any subclass specific initialization should be done in the default no-arg constructor for the subclass. That Constructor will be instantiated and invoked automatically by this main startup method.
By default will seek an AppMap.order file. However, the user can specify an alternate AppMap order file by using the following JVM argument:
By default, a Debug Log is usually enabled and named in the test configuration (INI) file. The user can specify or override the name of this debug log file by using the following JVM argument:
args
- --
-safsvar:name=value
-safsvar:platform=win8 -safsvar:browserType=firefox "-safsvar:spacedpath=C:\Project With Spaces\Special Directory"
-autorunclass -- followed by the class that is requesting the automatic configuration and execution, only take effect when parameter '-autorun' is present.
-junit:classname -- perform a JUnit test instead of executing runTest() in the SAFSPlus subclass.
The normal SAFSPlus bootstrap process and initialization is performed prior to executing the JUnit test.
AutoConfigureJSAFS
,
JSAFSBefore
,
JSAFSAfter
,
JSAFSTest
,
InjectJSAFS
public static void setLeveledTest(boolean leveledTest)
Copyright © SAS Institute. All Rights Reserved.