public class AISearchBase extends SeleniumPlus
There can be no invokable step definition methods in this class since no true step definition file is allowed to be extended.
To execute a Cucumber test based on this class:
Alternatively, you might be able to call the static runCukesTest(String, String) method from anywhere to run one or more Cucumber invocations.
The following JARs must be in the JVM CLASSPATH for such a Unit test invocation. This is the same as any other SeleniumPlus test invocation:
pathTo/yourClasses/bin or yourTest.jar, pathTo/seleniumplus.jar, pathTo/JSTAFEmbedded.jar, (or JSTAF.jar if using STAF and other external tools or engines.)Then, you can execute this test with an invocation similar to:
java -cp %CLASSPATH% td.testcases.stepdefs.AISearchBase
SeleniumPlus.Assert, SeleniumPlus.CheckBox, SeleniumPlus.ComboBox, SeleniumPlus.Component, SeleniumPlus.Counters, SeleniumPlus.EditBox, SeleniumPlus.Files, SeleniumPlus.ListView, SeleniumPlus.Logging, SeleniumPlus.Menu, SeleniumPlus.Misc, SeleniumPlus.Rest, SeleniumPlus.ScrollBar, SeleniumPlus.Strings, SeleniumPlus.TabControl, SeleniumPlus.Tree, SeleniumPlus.WDTimeOut, SeleniumPlus.Window
SAFSPlus.DriverCommand
Modifier and Type | Field and Description |
---|---|
protected static boolean |
_abort_on_assert_failure
default: false
|
protected static boolean |
_abort_on_find_failure
default: true
|
protected static boolean |
_case_does_not_matter
default: false
|
protected static boolean |
_log_details
default: true
|
protected static boolean |
_substring_matches_allowed
default: false
|
protected static boolean |
_using_cached_component
default: false
|
protected java.util.Map<java.lang.String,Component> |
cachedLibComponents
a cache holding the library component
|
static java.lang.String |
DEFAULT_SEPLUS_AI_DEFINITIONS
org.safs.cukes.ai.selenium The default package containing the step definitions.
|
protected static java.util.List<Arbre<SearchObject.FrameElement>> |
frames
a list of frame nodes, each node contains its parent frames to the root.
|
protected static Arbre<SearchObject.FrameElement> |
frameTree
the frame tree of the whole html document
|
static java.lang.String |
GLUE_OPT
--glue the option for cucumber runtime builder.
|
protected org.openqa.selenium.SearchContext |
searchContext
The context to find WebElements.
It is normally a WebDriver but it also can be a WebElement (the WebElement representing the parent) if we specify the recognition string as parent.child format. |
PRODUCT_DESCRIPTION, PRODUCT_NAME, PRODUCT_VERSION, Runner, TEMP_SELENIUM_PLUS_RS_VAR
_autorun, _autorunClassProvided, _injectDataAwareness, _isInjected, _isSPC, _junit, allowExit, ARG_AUTORUN, ARG_AUTORUN_CLASS, ARG_JUNIT, ARG_SAFSVAR, DefaultRunner, exitCode, normalizeTextForInput, prevResults, RELATIVE_TO_PARENT, RELATIVE_TO_SCREEN, springApplicationContext
Constructor and Description |
---|
AISearchBase() |
Modifier and Type | Method and Description |
---|---|
static java.util.List<org.openqa.selenium.WebElement> |
addNonRepeatedElements(java.util.List<org.openqa.selenium.WebElement> results,
java.util.List<org.openqa.selenium.WebElement> elements)
Find the non-repeated elements from the parameter 'elements' and add them into 'results'.
Currently we compare the web-element's id, if 2 elements have the same ID, we consider them same. |
static java.util.List<java.lang.String> |
convertElementArrayToList(Element[] elements)
Get the text of each element object in an array, and add it to a list, then return the list.
|
protected java.io.File |
deduceBenchFile(java.lang.String filename)
Deduce the absolute full path bench-relative file.
|
protected java.io.File |
deduceDiffFile(java.lang.String filename)
Deduce the absolute full path Diff-relative file.
|
protected java.io.File |
deduceProjectFile(java.lang.String filename)
Deduce the absolute full path to a project-relative file.
|
protected java.io.File |
deduceTestFile(java.lang.String filename)
Deduce the absolute full path test-relative file.
|
static org.openqa.selenium.WebElement |
findElementInParent(org.openqa.selenium.WebElement baseElement,
java.lang.String xpath,
int index)
Try to find the Nth matched element from the sub-nodes of parent of current node,
if not found then we go to the grand-parent to search again, and so on.
|
protected java.util.List<org.openqa.selenium.WebElement> |
findElements(Criteria criteria)
Find the WebElements according to the search Criteria.
In this method we firstly find the WebElements by SeleniumPlus-Library (the frame may get switched if the RS containing information about frame). In not found, we try to find WebElements in AI way, Criteria's component RS will be treated as the anchor-label to search components around. |
static java.util.List<org.openqa.selenium.WebElement> |
findElementsInParent(org.openqa.selenium.WebElement baseElement,
java.lang.String xpath)
Try to find the matched elements from the sub-nodes of parent of current node,
if not found then we go to the grand-parent to search again, and so on.
|
org.openqa.selenium.WebElement |
findSelectableItemFromText(java.lang.String text)
Find the first WebElement whose text matches the provided text.
The search will be tried on each frame until we find the first matched element. Note: Once this method is done, we should have switched to a certain frame. If substring matches are enabled, then we will also attempt partial substring matches. If the search is slow, this might be caused by the timeout, we can accelerate by calling AIMiscActions.do_not_wait_if_a_component_is_not_ready() . |
protected Component |
getCachedLibComponent(Criteria criteria)
get the cached Component according to the key, which can be a text-label, xpath or css-selector ect.
|
static org.openqa.selenium.WebElement |
getFirstIFrame(RemoteDriver selenium)
Deprecated.
please use
initializeFrames(WebDriver) instead. |
protected java.lang.String |
getXpathType(java.lang.String type) |
protected java.util.List<Arbre<SearchObject.FrameElement>> |
initializeFrames(org.openqa.selenium.WebDriver selenium)
|
static void |
logElementIdInfo(org.openqa.selenium.WebElement element)
Collect and log important recognition information on an element and then log it for review.
Information like: |
static void |
logElementProperties(org.openqa.selenium.WebElement element)
Log 'properties' info on the provided WebElement as collected by WDLibrary.getProperties.
Also see the logElementIdInfo method for a comparison of items collected. |
static void |
logListElementsInfo(java.util.List<org.openqa.selenium.WebElement> elements) |
static void |
logMapKeyValues(java.util.Map<java.lang.String,java.lang.Object> map)
Log Map key=value pairs to the debug log for review.
Called internally by certain info collecting methods. |
static void |
main(java.lang.String[] args)
Invokes SeleniumPlus.main(args) when called by the JVM as the startup class.
|
protected boolean |
matched(org.openqa.selenium.WebElement element,
java.lang.String type)
Test if the element's type can match what is expected.
|
protected void |
resetFrames()
|
static void |
runCukesTest(java.lang.String features)
Starts a Cucumber Runtime and executes Cucumber test(s) with the default step definitions in package
DEFAULT_SEPLUS_AI_DEFINITIONS . |
static void |
runCukesTest(java.lang.String features,
java.lang.String... glues)
Starts a Cucumber Runtime and executes Cucumber test(s) with the glues and feature file specs provided.
|
static void |
runCukesTest(java.lang.String glue,
java.lang.String features)
Starts a Cucumber Runtime and executes Cucumber test(s) with the glue and feature file specs provided.
|
void |
runTest()
Currently does nothing.
|
protected void |
saveCachedLibComponent(Criteria criteria,
Component component)
put the Component into the cache by the key, which can be a text-label, xpath or css-selector ect.
|
AbortTest, AltLeftDrag, Click, ClickUnverified, CtrlAltLeftDrag, CtrlClick, CtrlLeftDrag, CtrlRightClick, CtrlShiftLeftDrag, deduceFilterAreas, DoubleClick, executeAsyncScript, ExecuteScript, executeScript, GetGUIImage, GetGUIImage, getObject, getObject, GetVariableValue, Highlight, HoverScreenLocation, LeftDrag, Pause, PrintTestCaseSummary, PrintTestSuiteSummary, RightClick, RightDrag, SetVariableValue, ShiftClick, ShiftLeftDrag, StartTestCase, StartTestSuite, StartWebBrowser, StopTestCase, StopWebBrowser, SwitchWebBrowser, TypeChars, TypeEncryption, TypeKeys, VerifyBinaryFileToFile, VerifyFileToFile, VerifyGUIImageToFile, VerifyTextFileToFile, VerifyValueContains, VerifyValueContainsIgnoreCase, VerifyValueDoesNotContain, VerifyValues, VerifyValuesIgnoreCase, VerifyValuesNotEqual, WaitForGUI, WebDriver
_getMappedValue, _getVariable, _processArgs, _resolveDDVariables, _setVariable, action, actionGUILess, autorun, back, combineParams, command, debug, error, forward, getAllowExit, getExitCode, getRunner, iDriver, normalizeTextForInput, quote, quotePath, replaceSeparator, setAllowExit, setExitCode, setLeveledTest, setNormalizeTextForInput, setRunner, testStatusCode
protected static boolean _substring_matches_allowed
protected static boolean _case_does_not_matter
protected static boolean _abort_on_find_failure
protected static boolean _abort_on_assert_failure
protected static boolean _using_cached_component
protected static boolean _log_details
protected java.util.Map<java.lang.String,Component> cachedLibComponents
protected org.openqa.selenium.SearchContext searchContext
findElements(Criteria)
protected static Arbre<SearchObject.FrameElement> frameTree
protected static java.util.List<Arbre<SearchObject.FrameElement>> frames
public static final java.lang.String GLUE_OPT
public static final java.lang.String DEFAULT_SEPLUS_AI_DEFINITIONS
protected Component getCachedLibComponent(Criteria criteria)
protected void saveCachedLibComponent(Criteria criteria, Component component)
protected java.util.List<org.openqa.selenium.WebElement> findElements(Criteria criteria)
criteria
- Criteria, the conditions helping to find elementspublic static void logMapKeyValues(java.util.Map<java.lang.String,java.lang.Object> map)
map
- logElementProperties(WebElement)
,
logElementIdInfo(WebElement)
public static void logElementProperties(org.openqa.selenium.WebElement element)
element
- SearchObject.getProperties(WebElement)
,
logMapKeyValues(Map)
,
logElementIdInfo(WebElement)
public static void logElementIdInfo(org.openqa.selenium.WebElement element)
element
- - WebElement to collect and log important attributes.logMapKeyValues(Map)
public static void logListElementsInfo(java.util.List<org.openqa.selenium.WebElement> elements)
elements
- -- List of WebElements to be iteratively sent to logElementIdInfologElementIdInfo(WebElement)
@Deprecated public static org.openqa.selenium.WebElement getFirstIFrame(RemoteDriver selenium)
initializeFrames(WebDriver)
instead.selenium
- - RemoteDriver controlling the web session of interest.protected java.lang.String getXpathType(java.lang.String type)
type
- String, represents the WebElement's type, such as "ComboBox", "Button" etc.protected boolean matched(org.openqa.selenium.WebElement element, java.lang.String type)
element
- WebElement, the element to check.type
- String, the expected type, such as EditBox, RadioButton, ComboBox etc.protected void resetFrames()
protected java.util.List<Arbre<SearchObject.FrameElement>> initializeFrames(org.openqa.selenium.WebDriver selenium)
selenium
- WebDriverpublic static java.util.List<org.openqa.selenium.WebElement> findElementsInParent(org.openqa.selenium.WebElement baseElement, java.lang.String xpath)
baseElement
- WebElement, from whose parent to searchxpath
- String, the xpath served as search-conditionspublic static org.openqa.selenium.WebElement findElementInParent(org.openqa.selenium.WebElement baseElement, java.lang.String xpath, int index)
baseElement
- WebElement, from whose parent to searchxpath
- String, the xpath served as search-conditionsindex
- int, the Nth matched itempublic org.openqa.selenium.WebElement findSelectableItemFromText(java.lang.String text)
AIMiscActions.do_not_wait_if_a_component_is_not_ready()
.
text
- StringAIMiscActions.accept_partial_text_matches()
,
AIMiscActions.deny_partial_text_matches()
,
AIMiscActions.do_not_wait_if_a_component_is_not_ready()
public static java.util.List<org.openqa.selenium.WebElement> addNonRepeatedElements(java.util.List<org.openqa.selenium.WebElement> results, java.util.List<org.openqa.selenium.WebElement> elements)
results
- List<WebElement>, the destination list into which we add elementselements
- List<WebElement>, the list of elements to be addedprotected java.io.File deduceTestFile(java.lang.String filename) throws SAFSException
filename,
- String, the test/actual file name. If there are any File.separators in the
relative path then the path is actually considered relative to the Datapool
directory unless it does not exist, or is already an absolute file path.
If a relative directory path does not exist relative to the Datapool directory then the final path will be relative to the Project directory.
If it is an absolute path, and contains a root path that includes the Bench directory, then the file will be converted to a comparable relative path off the Test directory.
SAFSException
FileUtilities.deduceFile(String, int, RuntimeDataInterface)
protected java.io.File deduceDiffFile(java.lang.String filename) throws SAFSException
filename,
- String, the diff file name. If there are any File.separators in the
relative path then the path is actually considered relative to the Datapool
directory unless it does not exist, or is already an absolute file path.
If a relative directory path does not exist relative to the Datapool directory then the final path will be relative to the Project directory.
If it is an absolute path, and contains a root path that includes the Bench directory, then the file will be converted to a comparable relative path off the Diff directory.
SAFSException
FileUtilities.deduceFile(String, int, RuntimeDataInterface)
protected java.io.File deduceBenchFile(java.lang.String filename) throws SAFSException
filename,
- String, the test file name. If there are any File.separators in the
relative path then the path is actually considered relative to the Datapool
directory unless it does not exist, or is already an absolute file path.
If a relative directory path does not exist relative to the Datapool directory then
the final path will be relative to the Project directory.SAFSException
FileUtilities.deduceFile(String, int, RuntimeDataInterface)
protected java.io.File deduceProjectFile(java.lang.String filename) throws SAFSException
filename,
- String, the test file name. The path is ALWAYS considered relative
to the project root directory regardless of the absence or presence of File.separators
unless the file is already an absolute path.SAFSException
FileUtilities.deduceFile(String, int, RuntimeDataInterface)
public static java.util.List<java.lang.String> convertElementArrayToList(Element[] elements)
elements
- Element[], an array of element objectpublic static void runCukesTest(java.lang.String features) throws java.lang.Throwable
DEFAULT_SEPLUS_AI_DEFINITIONS
.
Examples:
DEFAULT_SEPLUS_AI_DEFINITIONS
,
and locates the single AltSearchAI.feature file to runs that test in Cucumber.
DEFAULT_SEPLUS_AI_DEFINITIONS
,
and locates the ./resources/features directory to runs tests based on the feature files found there.
features
- String, the path to the directory of feature files, or the specific feature file to run.java.lang.Throwable
public static void runCukesTest(java.lang.String glue, java.lang.String features) throws java.lang.Throwable
Examples:
glue
- String, the Java package root containing the Java Step Definition files to use.features
- String, the path to the directory of feature files, or the specific feature file to run.java.lang.Throwable
java.lang.Thread#getContextClassLoader()}
public static void runCukesTest(java.lang.String features, java.lang.String... glues) throws java.lang.Throwable
Examples:
features
- String, the path to the directory of feature files, or the specific feature file to run.glues
- String[], the Java packages containing the Java Step Definition files to use.java.lang.Throwable
java.lang.Thread#getContextClassLoader()}
public void runTest() throws java.lang.Throwable
public static void main(java.lang.String[] args)
args
- Copyright © SAS Institute. All Rights Reserved.