public class SearchObject
extends java.lang.Object
Supports various recognition string syntax, to include:
FRAMEINDEX=N;\; (1-based, 1 means the first frame) FRAMEID=id;\; FRAMENAME=name;\; FRAMEXPATH=//iframe[@id='frameId'];\; (note: parent/child elements separated by ";\;" ) (note: FRAMEINDEX is NOT ready for using ) (note: If there is no frame-expression in a RS, the last visited frame will be the frame where to find component. By default, the last visited frame is the main frame (the topmost html Document). And that is why if we specify frame for a window, then their children doesn't need to specify the frame information anymore. For example: [HelpPopup] HelpPopup="FRAMEID=VisualAnalyticsHubLogon_iframe;\;id=__popover8-popover" BtnHelpCenter="id=__item23" BtnHelpCenter is supposed to be found in frame 'VisualAnalyticsHubLogon_iframe' )
Identify any supported "TYPE" qualifier, if desired:
TYPE=DOJOTabControl; TYPE=DOJOToolbar; TYPE=SAPTabControl; TYPE=SAPToolbar; (see [doclink here] for supported domain classes) (note: type qualifier also includes domain information, like "DOJO", "SAP") (note: type qualifier and attribute identifiers separated by semi-colons)
Identify unique element attribute identifiers like:
ID=id; CLASS=class; NAME=name; TEXT=text; TITLE=title; LINK=linkInfo; PARTIALLINK=partialLinkInfo; TAG=tagname; (note: multiple attribute identifiers separated by semi-colons ;)
Identify element by multiple native attributes:
property1=xxx;property2=yyy;property3=zzz;
Identify explicit XPATH or CSS recognition:
XPATH=explicit xpath CSS=explicit css path
Identify any supported qualifier, if desired:
INDEX=n; (1-based, NOT used alone, indicates the Nth matched) ITEMINDEX=n; (1-based, NOT used alone, indicates the Nth item in a List, or ComboBox etc.) PATH=parent->child->grandchild; (NOT used alone, indicates the sub-item in a List, ComboBox, Menu or Tree etc.) PROPERTY=prop:value; (can be used with others to enforce search condition) PROPERTYCONTAINS=prop:partialValue; (can be used with others to enforce search condition) (note: multiple qualifiers separated by semi-colons ;) (note: these "ID", "TEXT", "ITEMINDEX", "PATH" will normally be considered as qualifier, but if there is a prefix :PASM: infront, they will be considered as component's native properties too. Example: For "TEXT=myList;componentProperty=xxx;ITEMINDEX=n;" "TEXT" and "ITEMINDEX" are qualifiers, while "componentProperty" is native property For ":PASM:TEXT=myList;componentProperty=xxx;ITEMINDEX=n;" "TEXT", "ITEMINDEX" and "componentProperty" are all native properties )
Modifier and Type | Class and Description |
---|---|
static class |
SearchObject.BrowserWindow |
protected static class |
SearchObject.DefaultJSEventListener
A default javascript event listener.
Usage example: |
static class |
SearchObject.DOJO
Inner class to handle DOJO-specific functionality.
|
protected static class |
SearchObject.FrameElement |
static interface |
SearchObject.GenericJSEventListener
A generic javascript event listener interface.
History: Apr 14, 2014 (Lei Wang) Initial release. |
static class |
SearchObject.HTML |
static class |
SearchObject.SAP |
static class |
SearchObject.SwitchFramesResults |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
assignSeparator
separates type and value for one qualifier.
|
static java.lang.String |
childSeparator
separates parent/child relationships in recognition strings.
|
static java.lang.String |
CSS_CLASS_DOJO_DIJIT_PREFIX
'dijit'
|
static java.lang.String |
CSS_CLASS_SAP_PREFIX
'sap'
|
static java.lang.String |
CSS_CLASS_SEPARATOR
' '
|
static java.lang.String |
CSS_SELECTOR_BY_CLASSNAME |
static java.lang.String |
CSS_SELECTOR_BY_ID |
static boolean |
DEFAULT_IGNORE_CASE
true
|
static int |
DEFAULT_JS_EXECUTION_DELAY
0
|
static long |
DEFAULT_JS_TIMEOUT
'5000' milliseconds
|
static boolean |
DEFAULT_PARTIAL_MATCH
false
|
static java.lang.String |
DOMAIN_DOJO
DOJO
|
static java.lang.String |
DOMAIN_HTML
HTML
|
static java.lang.String |
DOMAIN_SAP |
static java.lang.Character |
escapeChar
the character to escape separators.
|
static java.lang.String[] |
IGNORED_NONUI_TAGS
non-ui tags to be ignored in xpath searches and xpath generation.
|
static int |
INVALID_INDEX |
protected static java.util.Map<java.lang.String,SearchObject.GenericJSEventListener> |
jsEventListenerMap
A map containing pairs of (listenerID, listener).
|
protected static java.util.Map<java.lang.String,org.safs.selenium.webdriver.lib.SearchObject.PollingRunnable> |
jsEventListenerWaitingThreadMap
A map containing pairs of (listenerID, PollingRunnable).
|
protected static SearchObject.BrowserWindow |
lastBrowserWindow
The last visited browser window
|
protected static SearchObject.FrameElement |
lastFrame
The frame object where the current GUI-component locate.
|
protected static org.openqa.selenium.JavascriptExecutor |
lastJS
The Selenium 'JavascriptExecutor' currently used to execute javascript on the browser.
|
protected static org.openqa.selenium.WebDriver |
lastUsedWD
The Selenium 'WebDriver' currently used to manipulate the browser.
|
protected static java.lang.String |
lastVisitedURL
The last visited URL,
|
static int |
MATCHED_ONE_TIME
1 integer one
|
static int |
MATCHED_ZERO_TIMES
0 integer zero
|
static java.lang.String |
propertySeparator
separates property-name and property-value.
|
static java.lang.String |
qulifierSeparator
separates multiples qualifiers.
|
static java.lang.String |
SEARCH_CRITERIA_CLASS
CLASS
|
static java.lang.String |
SEARCH_CRITERIA_CLASS_CONTAINS
CLASSCONTAINS
|
static java.lang.String |
SEARCH_CRITERIA_CONTAINS_SUFFIX
"CONTAINS"
|
static java.lang.String |
SEARCH_CRITERIA_CSS
CSS
|
static java.lang.String |
SEARCH_CRITERIA_FRAMEID
FRAMEID, it should be placed in front of normal tokens like ID, CLASS, NAME etc.
|
static java.lang.String |
SEARCH_CRITERIA_FRAMEINDEX
FRAMEINDEX, it should be placed in front of normal tokens like ID, CLASS, NAME etc.
|
static java.lang.String |
SEARCH_CRITERIA_FRAMENAME
FRAMENAME, it should be placed in front of normal tokens like ID, CLASS, NAME etc.
|
static java.lang.String |
SEARCH_CRITERIA_FRAMEXPATH
FRAMEXPATH, it should be placed in front of normal tokens like ID, CLASS, NAME etc.
|
static java.lang.String |
SEARCH_CRITERIA_ID
ID
|
static java.lang.String |
SEARCH_CRITERIA_IFRAMEID
IFRAMEID, it should be placed in front of normal tokens like ID, CLASS, NAME etc.
|
static java.lang.String |
SEARCH_CRITERIA_INDEX
INDEX
|
static java.lang.String |
SEARCH_CRITERIA_ITEMINDEX
ITEMINDEX
|
static java.lang.String |
SEARCH_CRITERIA_LINK
LINK
|
static java.lang.String |
SEARCH_CRITERIA_NAME
NAME
|
static java.lang.String |
SEARCH_CRITERIA_PARTIALLINK
PARTIALLINK
|
static java.lang.String |
SEARCH_CRITERIA_PATH
PATH
|
static java.lang.String |
SEARCH_CRITERIA_PROPERTY
PROPERTY
|
static java.lang.String |
SEARCH_CRITERIA_PROPERTY_CONTAINS
PROPERTYCONTAINS
|
static java.lang.String |
SEARCH_CRITERIA_TAG
TAG
|
static java.lang.String |
SEARCH_CRITERIA_TEXT
TEXT
|
static java.lang.String |
SEARCH_CRITERIA_TITLE
TITLE
|
static java.lang.String |
SEARCH_CRITERIA_TYPE
TYPE
|
static java.lang.String |
SEARCH_CRITERIA_XPATH
XPATH
|
static java.lang.String |
TAG_FRAME
'frame' tag name
|
static java.lang.String |
TAG_IFRAME
'iframe' tag name
|
static java.lang.String[] |
TEXT_VALUE_ATTRIBUTES
"value","text","placeholder".
|
static java.lang.String |
XPATH_CHILD_SEPARATOR
separates parent/child relationships in recognition strings.
|
Constructor and Description |
---|
SearchObject() |
Modifier and Type | Method and Description |
---|---|
protected static SearchObject.SwitchFramesResults |
_switchFrames(java.lang.String recognitionString)
Before doing any component search, we make sure we are in the correct frame.
|
static java.lang.String |
addJavaScriptEventListener(org.openqa.selenium.WebElement element,
java.lang.String eventName,
SearchObject.GenericJSEventListener listener) |
protected static org.openqa.selenium.WebDriver |
addWebDriver(java.lang.String id,
org.openqa.selenium.WebDriver wd)
Store the WebDriver in the Hashtable by id.
This also sets this WebDriver as the "current" or "lastUsed" WebDriver. |
(package private) static boolean |
checkCSSClassName(org.openqa.selenium.WebElement element,
java.lang.String prefix,
java.lang.String separator)
To check if the html tag's css class name containing a certain prefix.
|
static void |
checkNotNull(java.lang.Object object)
Check that the object is not null.
|
static boolean |
clearHighlight()
clear the previous highlight of a webelement.
Note:The webelement should be highlighted by highlight(String) or highlight(WebElement) , normally you don't need to call this methodto clear the highlight if you want to highlight element one by one continuously, as the previous highlighted element will be automatically cleared before next element is highlighted. |
static boolean |
containFrameRS(java.lang.String rs) |
static boolean |
containTagRS(java.lang.String rs) |
static java.lang.Object |
executeAsyncScript(java.lang.String script,
java.lang.Object... args) |
static java.lang.Object |
executeJavaScriptOnWebElement(java.lang.String script,
org.openqa.selenium.WebElement webelement,
java.lang.Object... args) |
static java.lang.Object |
executeScript(boolean synch,
java.lang.String script,
java.lang.Object... args)
Execute a section of java-script code.
It has the ability to detect a javascript error and throw an JSException. |
static java.lang.Object |
executeScript(java.lang.String script,
java.lang.Object... args) |
static org.openqa.selenium.WebElement |
findElement(org.openqa.selenium.By by) |
protected static java.util.List<org.openqa.selenium.WebElement> |
findElements(org.openqa.selenium.SearchContext wel,
java.lang.String xpath) |
static java.lang.String |
generateFullGenericXPath(org.openqa.selenium.WebElement element)
Attempt to generate a full generic Xpath string for this element including all parent
path information.
|
static java.lang.String |
generateGenericXPath(org.openqa.selenium.WebElement element)
Attempt to generate a simple Xpath string for this one element without any parent
path information.
|
static java.lang.String |
generateSAFSFrameRecognition(java.lang.String framexpath)
Attempt to generate a simple frame recognition string without any parent path information.
|
static java.lang.String |
generateUniqueName(java.lang.String prefix)
Deprecated.
This method has been moved to StringUtils, we can call StringUtils.generateUniqueName() directly.
|
static java.lang.String[] |
getAllWindowTitles() |
static boolean |
getBoolean(org.openqa.selenium.WebElement webelement,
java.lang.String... attributes)
Get a boolean value from the WebElement according to the attributes.
|
static java.lang.String |
getCssSelector(java.lang.String type,
org.openqa.selenium.WebElement element)
According to the type, generate a css selector for the WebElement.
|
(package private) static java.lang.String |
getDescription(org.openqa.selenium.WebElement element)
Return a string to describe a selenium web element.
|
protected static java.lang.String[] |
getFirstQualifierPair(java.lang.String RS)
Split a string by separator
assignSeparator , and return the result.If the RS contains multiple assignSeparator , this method will ONLYconsider the first separator, the string before that separator will be considered as qualifier; the string after will be all considered as value. |
protected static org.openqa.selenium.WebElement |
getFrameWebElement(org.openqa.selenium.SearchContext sc,
int index)
Find the Nth frame webelement in the search context.
|
static java.lang.String |
getIDForWebDriver(org.openqa.selenium.WebDriver wd)
At this time does NOT set the processed WebDriver to be the "current" or "lastUsed" WebDriver.
|
static org.openqa.selenium.JavascriptExecutor |
getJS() |
static int |
getJsExecutionDelay() |
static long |
getJsTimeout() |
static SearchObject.BrowserWindow |
getLastBrowserWindow() |
static SearchObject.FrameElement |
getLastFrame()
The frame object where the current GUI-component locate.
|
static java.lang.String |
getLastVisitedURL() |
protected static org.openqa.selenium.SearchContext |
getMatchedObject(java.util.List<org.safs.selenium.webdriver.lib.SearchObject.WebElementWarpper> elements,
java.lang.String value,
boolean partialMatch) |
protected static java.util.List<org.openqa.selenium.WebElement> |
getMatchedObjects(java.util.List<org.safs.selenium.webdriver.lib.SearchObject.WebElementWarpper> elements,
java.lang.String value,
boolean partialMatch) |
protected static org.openqa.selenium.WebElement |
getNthWebElement(java.util.List<org.openqa.selenium.WebElement> preMatches,
int matchindex,
java.lang.String typeInSAFS)
Find the Nth matched WebElement in a list.
|
static org.openqa.selenium.WebElement |
getObject(org.openqa.selenium.SearchContext sc,
java.lang.String recognitionString)
Primary entry point to seek a WebElement based on a provided recognition string.
|
static org.openqa.selenium.WebElement |
getObject(java.lang.String RS)
Get the object based on the recognition string.
|
protected static org.openqa.selenium.SearchContext |
getObjectByMultiAttributes(org.openqa.selenium.SearchContext sc,
java.lang.String RS,
boolean isPASM)
Builds an XPath search string using multiple attributes provided in the recognition string
then performs a findElement(By.xpath(string));
If the recognition string contains special attributes, How to tell them from normal attributes???
|
protected static org.openqa.selenium.SearchContext |
getObjectByQualifier(org.openqa.selenium.SearchContext sc,
java.lang.String qualifier,
java.lang.String value)
According to pair(qualifier, value), find the matched WebElement.
Some qualifiers like "ID", can determine the WebElement uniquely and result only one WebElement; Other qualifiers may result several WebElement, the first one will be returned. |
protected static org.openqa.selenium.SearchContext |
getObjectByText(org.openqa.selenium.SearchContext wel,
java.lang.String text,
boolean partialMatch) |
protected static org.openqa.selenium.SearchContext |
getObjectByTitle(org.openqa.selenium.SearchContext wel,
java.lang.String value,
boolean partialMatch) |
protected static org.openqa.selenium.WebElement |
getObjectByXpathAndQualifiers(org.openqa.selenium.SearchContext sc,
java.lang.String xpathStr,
java.util.HashMap<java.lang.String,java.lang.String> qualifiers)
According to xpath and qualifiers to find the WebElement.
|
protected static org.openqa.selenium.WebElement |
getObjectForDomain(org.openqa.selenium.SearchContext sc,
java.lang.String RS,
boolean isPropertyAllMode)
Alternate search for special framework elements like Dojo or SAP OpenUI5 components.
|
static java.util.List<org.openqa.selenium.WebElement> |
getObjects(org.openqa.selenium.SearchContext sc,
java.lang.String recognitionString)
Primary entry point to seek all WebElements matching a provided recognition string.
|
protected static java.util.List<org.openqa.selenium.WebElement> |
getObjectsByMultiAttributes(org.openqa.selenium.SearchContext sc,
java.lang.String RS,
boolean isPASM)
Builds an XPath search string using multiple attributes provided in the recognition string
then performs a findElements(By.xpath(string));
If the recognition string contains special attributes, How to tell them from normal attributes???
|
protected static java.util.List<org.openqa.selenium.WebElement> |
getObjectsByQualifier(org.openqa.selenium.SearchContext sc,
java.lang.String qualifier,
java.lang.String value)
According to pair(qualifier, value), find all matching WebElements.
Some qualifiers like "ID", can determine the WebElement uniquely and result only one WebElement; Other qualifiers may result in several WebElements. |
protected static java.util.List<org.openqa.selenium.WebElement> |
getObjectsByText(org.openqa.selenium.SearchContext wel,
java.lang.String text,
boolean partialMatch) |
protected static java.util.List<org.openqa.selenium.WebElement> |
getObjectsByTitle(org.openqa.selenium.SearchContext wel,
java.lang.String value,
boolean partialMatch) |
protected static java.util.List<org.openqa.selenium.WebElement> |
getObjectsByXpathAndQualifiers(org.openqa.selenium.SearchContext sc,
java.lang.String xpathStr,
java.util.HashMap<java.lang.String,java.lang.String> qualifiers)
According to xpath and qualifiers to find matching WebElements.
While returning a List, it is likely the List will have only 1 matching item. |
protected static java.util.List<org.openqa.selenium.WebElement> |
getObjectsForDomain(org.openqa.selenium.SearchContext sc,
java.lang.String RS,
boolean isPropertyAllMode)
Alternate search for special framework elements like Dojo or SAP OpenUI5 components.
|
static org.openqa.selenium.WebElement |
getParentWebElement(org.openqa.selenium.WebElement element)
Return the parent WebElement of the provided WebElement.
|
protected static org.openqa.selenium.WebElement |
getSubItem(org.openqa.selenium.WebElement itemContainer,
TextMatchingCriterion criterion)
According to TextMatchingCriterion to get the sub item within a container WebElement.
|
protected static java.lang.String |
getTagQualifierValue(java.lang.String RS)
Example: tag=span;propertycontains=innerHTML:some value
|
static java.lang.String |
getText(org.openqa.selenium.WebElement webelement)
Attempts to retrieve a text value for the WebElement.
|
protected static java.lang.String |
getThrowableMessages(java.lang.Throwable th) |
static java.lang.Object |
getValue(org.openqa.selenium.WebElement webelement,
java.lang.String... attributes)
Get a value from the WebElement according to the attributes.
The first non-null-value of the attributes will be returned, so the order of attributes may affect the result. |
static org.openqa.selenium.WebDriver |
getWebDriver()
Get the last used "current" WebDriver.
|
protected static org.openqa.selenium.WebDriver |
getWebDriver(java.lang.String id)
At this time does NOT set the retrieved WebDriver to be the "current" or "lastUsed" WebDriver.
|
protected static org.openqa.selenium.WebDriver |
getWebDriverWithTitle(java.lang.String title) |
protected static org.openqa.selenium.WebElement |
getWebElement(org.openqa.selenium.SearchContext sc,
java.lang.String tagName,
int index)
Find the Nth tag in the search context.
|
static java.lang.Object |
getWebElementProperty(org.openqa.selenium.WebElement element,
java.lang.String property)
Return the specified property of a WebElement.
For example, we can get the parentNode of a WebElement by calling this method with "parentNode" as the property. |
protected static java.lang.String |
getXpathCondition(java.lang.String propertyValuePairStr,
boolean partialMatch) |
static boolean |
highlight(java.lang.String idOrNameOrXpath)
Highlight the webelement by drawing a red rectangle around it.
|
static boolean |
highlight(org.openqa.selenium.WebElement webelement)
Highlight the webelement by drawing a red rectangle around it.
To clean the red rectangle, please call clearHighlight() . |
static boolean |
highlightThenClear(org.openqa.selenium.WebElement webelement,
int duration)
Highlight the webelement by drawing a red rectangle around it.
|
static boolean |
isDisplayed(org.openqa.selenium.WebElement element)
Check if the webelement is displayed (Selenium's API isDisplayed()).
|
static boolean |
isDojoDomain(org.openqa.selenium.WebElement element)
To test if the WebElement belongs to DOJO Domain.
|
protected static boolean |
isFrameRS(java.lang.String recognitionString) |
static boolean |
isFrameWebElement(org.openqa.selenium.WebElement frameTag) |
static boolean |
isIgnoredNonUITag(java.lang.String tag) |
static boolean |
isSAPDomain(org.openqa.selenium.WebElement element)
To test if the WebElement belongs to SAP OPENUI5 Domain.
|
static boolean |
isStale(org.openqa.selenium.WebElement element)
Test if a WebElement is stale(DOM element is deleted or is repaint or disappear).
|
static boolean |
isValidBrowserID(java.lang.String ID)
if the id is valid (not null and not empty).
|
static boolean |
isValidFrameRS(java.lang.String frameRS) |
static boolean |
isVisible(org.openqa.selenium.WebElement element)
Get the visibility of the webelement.
Try Selenium's API isDisplayed() firstly, if it is false then try to test value of attribute 'visibility'. |
static void |
js_cleanError()
Clean the global variable
JavaScriptFunctions.SAFS_JAVASCRIPT_GLOBAL_ERROR_CODE_VAR ,reset it value to JavaScriptFunctions.ERROR_CODE_NOT_SET . |
protected static java.lang.Object |
js_executeWithTimeout(java.lang.String js,
long msTimeout) |
static int |
js_getErrorCode()
Get the value of global variable
JavaScriptFunctions.SAFS_JAVASCRIPT_GLOBAL_ERROR_CODE_VAR . |
static java.lang.Object |
js_getErrorObject()
Get the value of global variable
JavaScriptFunctions.SAFS_JAVASCRIPT_GLOBAL_ERROR_OBJECT_VAR . |
static boolean |
js_getGlobalBoolVariable(java.lang.String variable)
Get the boolean value of a javascript global variable.
|
static java.lang.Object |
js_getGlobalVariable(java.lang.String variable)
Get the value of a javascript global variable.
|
static void |
js_initError()
Initialize the global variable
JavaScriptFunctions.SAFS_JAVASCRIPT_GLOBAL_ERROR_CODE_VAR ,set it value to JavaScriptFunctions.ERROR_CODE_NOT_SET . |
protected static void |
js_initialize()
Execute javascript to initialize global javascript variables.
|
static void |
js_setErrorCode(int error)
Set the value of global variable
JavaScriptFunctions.SAFS_JAVASCRIPT_GLOBAL_ERROR_CODE_VAR |
static void |
js_setErrorObject(java.lang.String errorMessage)
Set a string value to global variable
JavaScriptFunctions.SAFS_JAVASCRIPT_GLOBAL_ERROR_OBJECT_VAR |
static void |
js_setGlobalBoolVariable(java.lang.String variable,
boolean onOrOff)
Get the value for a javascript global boolean variable.
|
static void |
js_setGlobalVariable(java.lang.String variable,
java.lang.String value)
Set the value for a javascript global variable.
|
static boolean |
pageHasChanged()
To detect if the page has changed or not.
For example, if user click on a link, or a Log-Out menu item, the page may probably change. The current implementation is not guarantee! |
protected static org.openqa.selenium.WebDriver |
reconnectLastWebDriver()
Will only connect to the "current" session.
|
static void |
refreshJSExecutor()
Use the
lastUsedWD to refresh the lastJS . |
static void |
removeJavaScriptEventListener(org.openqa.selenium.WebElement element,
java.lang.String eventName,
java.lang.String listenerID)
Note: It is important to call this method in a finally clause to make sure that the polling thread stop.
|
protected static org.openqa.selenium.WebDriver |
removeWebDriver(java.lang.String id)
Removes the provided webdriver from internal storage and deletes the session info
in the RemoteDriver.
|
static void |
resetXPathObjectCache()
reset the internal xpath object cache for a new round of full xpath generation.
|
protected static java.lang.String |
retrieveFrameRS(java.lang.String recognitionString)
if the frame-RS is specified as one qualifier of RS, find and return it.
For example, for "FrameID=yyy;property=xxx;property=xxx", we return "FrameID=yyy" The rest "property=xxx;property=xxx" is not useful for now, as FrameId, FrameName and FrameXpath, they are enough to find a frame. |
protected static void |
setJsExecutionDelay(int milliseconds)
NOTE:Sometimes we needs to wait for the WEB page FULLY loaded so that the javascript code can
return correctly.
Please set this delay back to DEFAULT_JS_EXECUTION_DELAY after a special javascript call,
otherwise the performance of the SeleniumPlus framework will be slowed down. |
static void |
setJsTimeout(long jsTimeout)
Set the timeout for javascript code to execute.
|
static void |
setLastFrame(SearchObject.FrameElement lastFrame)
Note: User should be very careful when calling this method,
it will change the whole searching context!!!
Set the frame object where the current GUI-component locate. |
static void |
shutdown()
Currently, shutdown will "quit()" every webdriver that is stored here.
|
static boolean |
switchFrame(org.openqa.selenium.WebDriver webdriver,
java.lang.String frameRS)
Switch to a certain frame according to the parameter frameRS.
Note: User should be extremely careful to call this method, which will change the frame to search within. Note: Before calling this method, make sure that webdriver.switchTo().defaultContent() is called. |
static boolean |
switchWindow(java.lang.String title,
boolean... optionals)
Switch to a certain window according to its title, this method will search it from all opened browsers.
NOTE: Once successfully switched, lastUsedWD , lastJS may probably get changed. |
static boolean |
switchWindow(java.lang.String title,
int expectedMatchIndex,
boolean... optionals)
Switch to a certain window according to its title, this method will search it from all opened browsers.
NOTE: Once successfully switched, lastUsedWD , lastJS may probably get changed. |
static boolean |
switchWindow(java.lang.String browserID,
java.lang.String title,
boolean... optionals)
Switch to a certain window according to its title within browser identified by parameter 'browserID'.
NOTE: Once successfully switched, lastUsedWD , lastJS may probably get changed. |
static int |
switchWindow(java.lang.String browserID,
java.lang.String title,
int expectedMatchIndex,
boolean... optionals)
Switch to a certain window according to its title within browser identified by parameter 'browserID'.
NOTE: Once successfully switched, lastUsedWD , lastJS may probably get changed. |
static void |
useBrowser(java.lang.String ID)
Switch to browser indicated by ID.
|
public static final java.lang.String[] TEXT_VALUE_ATTRIBUTES
getValue(WebElement, String...)
protected static org.openqa.selenium.WebDriver lastUsedWD
protected static org.openqa.selenium.JavascriptExecutor lastJS
protected static SearchObject.FrameElement lastFrame
getObject(SearchContext, String)
public static final java.lang.String SEARCH_CRITERIA_FRAMEINDEX
public static final java.lang.String SEARCH_CRITERIA_FRAMEID
public static final java.lang.String SEARCH_CRITERIA_IFRAMEID
public static final java.lang.String SEARCH_CRITERIA_FRAMENAME
public static final java.lang.String SEARCH_CRITERIA_FRAMEXPATH
public static final java.lang.String TAG_FRAME
public static final java.lang.String TAG_IFRAME
public static final java.lang.String SEARCH_CRITERIA_TYPE
public static final java.lang.String SEARCH_CRITERIA_ID
public static final java.lang.String SEARCH_CRITERIA_NAME
public static final java.lang.String SEARCH_CRITERIA_TEXT
public static final java.lang.String SEARCH_CRITERIA_PATH
public static final java.lang.String SEARCH_CRITERIA_PROPERTY
public static final java.lang.String SEARCH_CRITERIA_PROPERTY_CONTAINS
public static final java.lang.String SEARCH_CRITERIA_INDEX
public static final java.lang.String SEARCH_CRITERIA_CLASS_CONTAINS
public static final java.lang.String SEARCH_CRITERIA_ITEMINDEX
public static final java.lang.String SEARCH_CRITERIA_CLASS
public static final java.lang.String SEARCH_CRITERIA_TITLE
public static final java.lang.String SEARCH_CRITERIA_XPATH
public static final java.lang.String SEARCH_CRITERIA_CSS
public static final java.lang.String SEARCH_CRITERIA_LINK
public static final java.lang.String SEARCH_CRITERIA_PARTIALLINK
public static final java.lang.String SEARCH_CRITERIA_TAG
public static final java.lang.String SEARCH_CRITERIA_CONTAINS_SUFFIX
public static final java.lang.String DOMAIN_DOJO
public static final java.lang.String DOMAIN_SAP
public static final java.lang.String DOMAIN_HTML
public static final int INVALID_INDEX
public static final java.lang.String XPATH_CHILD_SEPARATOR
public static java.lang.String childSeparator
public static java.lang.String qulifierSeparator
public static java.lang.String assignSeparator
public static java.lang.String propertySeparator
public static java.lang.Character escapeChar
public static final java.lang.String[] IGNORED_NONUI_TAGS
protected static java.lang.String lastVisitedURL
protected static SearchObject.BrowserWindow lastBrowserWindow
public static final long DEFAULT_JS_TIMEOUT
protected static java.util.Map<java.lang.String,SearchObject.GenericJSEventListener> jsEventListenerMap
protected static java.util.Map<java.lang.String,org.safs.selenium.webdriver.lib.SearchObject.PollingRunnable> jsEventListenerWaitingThreadMap
public static final int DEFAULT_JS_EXECUTION_DELAY
public static final java.lang.String CSS_SELECTOR_BY_ID
public static final java.lang.String CSS_SELECTOR_BY_CLASSNAME
public static final java.lang.String CSS_CLASS_SEPARATOR
public static final java.lang.String CSS_CLASS_SAP_PREFIX
public static final java.lang.String CSS_CLASS_DOJO_DIJIT_PREFIX
public static final int MATCHED_ZERO_TIMES
public static final int MATCHED_ONE_TIME
public static final boolean DEFAULT_PARTIAL_MATCH
public static final boolean DEFAULT_IGNORE_CASE
public static SearchObject.FrameElement getLastFrame()
getObject(SearchContext, String)
public static void setLastFrame(SearchObject.FrameElement lastFrame)
getObject(SearchContext, String)
public static java.lang.String getLastVisitedURL()
public static SearchObject.BrowserWindow getLastBrowserWindow()
public static void shutdown() throws java.lang.Throwable
java.lang.Throwable
public static boolean isIgnoredNonUITag(java.lang.String tag)
tag
- IGNORED_NONUI_TAGS
protected static org.openqa.selenium.WebDriver addWebDriver(java.lang.String id, org.openqa.selenium.WebDriver wd)
WebDriver.quit()
id
- String, the key for the WebDriver to store in the Hashtable.wd
- WebDriver, the WebDriver to store in the Hashtable.public static void useBrowser(java.lang.String ID) throws SeleniumPlusException
lastUsedWD
and set the lastJS
if possible.ID
- String, the id to identify the browserSeleniumPlusException
protected static org.openqa.selenium.WebDriver getWebDriver(java.lang.String id)
id
- String, the ID for the WebDriver stored in the Hashtable.protected static org.openqa.selenium.WebDriver getWebDriverWithTitle(java.lang.String title)
title
- String, the case-insensitive title within the WebDriver stored in the Hashtable.public static java.lang.String getIDForWebDriver(org.openqa.selenium.WebDriver wd)
wd
- WebDriver to get our stored ID of.public static java.lang.String[] getAllWindowTitles()
protected static org.openqa.selenium.WebDriver reconnectLastWebDriver()
public static org.openqa.selenium.WebDriver getWebDriver()
public static boolean isValidBrowserID(java.lang.String ID)
ID
- String, the browser id.protected static org.openqa.selenium.WebDriver removeWebDriver(java.lang.String id)
id
- String, the ID for the WebDriver to removeisValidBrowserID(String)
, then the last used WebDriver will be removed.public static org.openqa.selenium.WebElement findElement(org.openqa.selenium.By by)
public static org.openqa.selenium.WebElement getObject(java.lang.String RS)
RS
- getObject(SearchContext, String)
public static boolean containTagRS(java.lang.String rs)
rs
- public static boolean containFrameRS(java.lang.String rs)
public static boolean isValidFrameRS(java.lang.String frameRS)
protected static boolean isFrameRS(java.lang.String recognitionString)
recognitionString
- Stringprotected static java.lang.String retrieveFrameRS(java.lang.String recognitionString)
recognitionString
- Stringpublic static boolean switchFrame(org.openqa.selenium.WebDriver webdriver, java.lang.String frameRS)
webdriver
- WebDriver, the webdriver used to search frame and switch frameframeRS
- String, the recognition string of the frameprotected static java.lang.String getTagQualifierValue(java.lang.String RS) throws com.thoughtworks.selenium.SeleniumException
RS
- -- Full MultiAttribute qualifier RS. (Does not have to be a single qualifier assignment segment.)
The algorithm does NOT assume the TAG qualifier is first in the RS.com.thoughtworks.selenium.SeleniumException
protected static java.lang.String[] getFirstQualifierPair(java.lang.String RS) throws com.thoughtworks.selenium.SeleniumException
assignSeparator
, and return the result.assignSeparator
, this method will ONLYRS
- String, a recognition with a assignSeparator
inside.com.thoughtworks.selenium.SeleniumException
- if the RS is not valid.public static boolean pageHasChanged()
protected static SearchObject.SwitchFramesResults _switchFrames(java.lang.String recognitionString)
recognitionString
- public static org.openqa.selenium.WebElement getObject(org.openqa.selenium.SearchContext sc, java.lang.String recognitionString)
sc
- SearchContext, could be the WebDriver or a parent WebElement context.recognitionString
- String, The recognition string used to identify the sought element.public static java.util.List<org.openqa.selenium.WebElement> getObjects(org.openqa.selenium.SearchContext sc, java.lang.String recognitionString)
sc
- SearchContext, could be the WebDriver or a parent WebElement context.recognitionString
- String, The recognition string used to identify the matching elements.public static boolean isFrameWebElement(org.openqa.selenium.WebElement frameTag)
protected static org.openqa.selenium.WebElement getFrameWebElement(org.openqa.selenium.SearchContext sc, int index)
sc
- SearchContext, the search context, SHOULD be WebDriverindex
- int, the index of the tag, 1-basedprotected static org.openqa.selenium.WebElement getWebElement(org.openqa.selenium.SearchContext sc, java.lang.String tagName, int index)
sc
- SearchContext, the search contexttagName
- String, the tag name to findindex
- int, the index of the tag, 1-basedprotected static java.util.List<org.openqa.selenium.WebElement> findElements(org.openqa.selenium.SearchContext wel, java.lang.String xpath)
protected static org.openqa.selenium.SearchContext getObjectByText(org.openqa.selenium.SearchContext wel, java.lang.String text, boolean partialMatch)
protected static java.util.List<org.openqa.selenium.WebElement> getObjectsByText(org.openqa.selenium.SearchContext wel, java.lang.String text, boolean partialMatch)
protected static org.openqa.selenium.SearchContext getObjectByTitle(org.openqa.selenium.SearchContext wel, java.lang.String value, boolean partialMatch)
protected static java.util.List<org.openqa.selenium.WebElement> getObjectsByTitle(org.openqa.selenium.SearchContext wel, java.lang.String value, boolean partialMatch)
protected static org.openqa.selenium.SearchContext getMatchedObject(java.util.List<org.safs.selenium.webdriver.lib.SearchObject.WebElementWarpper> elements, java.lang.String value, boolean partialMatch)
elements
- List<WebElementWarpper>, contains WebElement to matchvalue
- String, the value to match withpartialMatch
- boolean, if we try to find the partial matched itemprotected static java.util.List<org.openqa.selenium.WebElement> getMatchedObjects(java.util.List<org.safs.selenium.webdriver.lib.SearchObject.WebElementWarpper> elements, java.lang.String value, boolean partialMatch)
elements
- List<WebElementWarpper>, contains WebElements to matchvalue
- String, the value to match withpartialMatch
- boolean, if we try to find the partial matched itemprotected static org.openqa.selenium.SearchContext getObjectByQualifier(org.openqa.selenium.SearchContext sc, java.lang.String qualifier, java.lang.String value) throws SeleniumPlusException
sc
- SearchContext, the search context, it is normally a WebElement.qualifier
- String, the qualifier like xpath, css, id, name, link etc.value
- String, the value of a qualifier.SeleniumPlusException
protected static java.util.List<org.openqa.selenium.WebElement> getObjectsByQualifier(org.openqa.selenium.SearchContext sc, java.lang.String qualifier, java.lang.String value) throws SeleniumPlusException
sc
- SearchContext, the search context, it is normally a WebElement.qualifier
- String, the qualifier like xpath, css, id, name, link etc.value
- String, the value of a qualifier.SeleniumPlusException
protected static org.openqa.selenium.SearchContext getObjectByMultiAttributes(org.openqa.selenium.SearchContext sc, java.lang.String RS, boolean isPASM)
Builds an XPath search string using multiple attributes provided in the recognition string then performs a findElement(By.xpath(string)); If the recognition string contains special attributes, How to tell them from normal attributes???
sc
- SearchContext, the search contextRS
- String, the recognition stringisPASM
- boolean, if true, each part of 'recognition string' will be treated as property.SEARCH_CRITERIA_ITEMINDEX
, SEARCH_CRITERIA_PATH
etc.protected static java.util.List<org.openqa.selenium.WebElement> getObjectsByMultiAttributes(org.openqa.selenium.SearchContext sc, java.lang.String RS, boolean isPASM)
Builds an XPath search string using multiple attributes provided in the recognition string then performs a findElements(By.xpath(string)); If the recognition string contains special attributes, How to tell them from normal attributes???
sc
- SearchContext, the search contextRS
- String, the recognition stringisPASM
- boolean, if true, each part of 'recognition string' will be treated as property.SEARCH_CRITERIA_ITEMINDEX
, SEARCH_CRITERIA_PATH
etc.protected static org.openqa.selenium.WebElement getSubItem(org.openqa.selenium.WebElement itemContainer, TextMatchingCriterion criterion)
itemContainer
- WebElement, the container WebElement, like list, menu etc.criterion
- TextMatchingCriterion, holding the searching conditionprotected static org.openqa.selenium.WebElement getObjectByXpathAndQualifiers(org.openqa.selenium.SearchContext sc, java.lang.String xpathStr, java.util.HashMap<java.lang.String,java.lang.String> qualifiers)
sc
- SearchContext, the search context, it is normally a WebElement.xpathStr
- String, the xpath used to find a WebElmentqualifiers
- HashMapprotected static java.util.List<org.openqa.selenium.WebElement> getObjectsByXpathAndQualifiers(org.openqa.selenium.SearchContext sc, java.lang.String xpathStr, java.util.HashMap<java.lang.String,java.lang.String> qualifiers)
sc
- SearchContext, the search context, it is normally a WebElement.xpathStr
- String, the xpath used to find matching WebElementsqualifiers
- HashMapprotected static org.openqa.selenium.WebElement getNthWebElement(java.util.List<org.openqa.selenium.WebElement> preMatches, int matchindex, java.lang.String typeInSAFS)
preMatches
- List<WebElement>, a list of WebElment from where to find a matched Elementmatchindex
- int, the expected index, 1-basedtypeInSAFS
- String, the expected type, like "Button", "List", "CheckBox". If null, match all elements.protected static org.openqa.selenium.WebElement getObjectForDomain(org.openqa.selenium.SearchContext sc, java.lang.String RS, boolean isPropertyAllMode)
sc
- SearchContext, the search contextRS
- String, the recognition stringisPropertyAllMode
- boolean, if true, each part of 'recognition string' will be treated as property.SEARCH_CRITERIA_ITEMINDEX
, SEARCH_CRITERIA_PATH
etc.protected static java.util.List<org.openqa.selenium.WebElement> getObjectsForDomain(org.openqa.selenium.SearchContext sc, java.lang.String RS, boolean isPropertyAllMode)
sc
- SearchContext, the search contextRS
- String, the recognition stringisPropertyAllMode
- boolean, if true, each part of 'recognition string' will be treated as property.SEARCH_CRITERIA_ITEMINDEX
, SEARCH_CRITERIA_PATH
etc.protected static java.lang.String getXpathCondition(java.lang.String propertyValuePairStr, boolean partialMatch)
propertyValuePairStr
- String, the pair representing property and value, like property:value, separated by propertySeparator
partialMatch
- boolean, if the property's value will be matched partially (considered as a substring)#getXpathCondition(String, String, boolean)
public static boolean getBoolean(org.openqa.selenium.WebElement webelement, java.lang.String... attributes)
webelement
- WebElement, the WebElement to get value of an attribute.attributes
- String..., an array of attribute to get value for.public static java.lang.String getText(org.openqa.selenium.WebElement webelement)
webelement
- WebElement, the web element to get text from.public static java.lang.Object getValue(org.openqa.selenium.WebElement webelement, java.lang.String... attributes)
webelement
- WebElement, the WebElement to get value of an attribute.attributes
- String..., an array of attribute to get value for.TEXT_VALUE_ATTRIBUTES
public static boolean js_getGlobalBoolVariable(java.lang.String variable) throws java.lang.IllegalStateException
variable
- String, the name of the global variable.java.lang.IllegalStateException
- if the value is NOT present or attainable.js_getGlobalVariable(String)
public static void setJsTimeout(long jsTimeout)
jsTimeout
- long, timeout in milliseconds for the javascript execution to finishjs_getErrorCode()
,
js_getErrorObject()
,
js_getGlobalVariable(String)
public static long getJsTimeout()
protected static java.lang.Object js_executeWithTimeout(java.lang.String js, long msTimeout) throws SeleniumPlusException, java.lang.InterruptedException
js
- String, the javascript code to executemsTimeout
- long, the timeout in milliseconds for the javascript executionSeleniumPlusException
- if the timeout has been reachedjava.lang.InterruptedException
- if the thread (executing javascript) has been interruptedpublic static java.lang.Object js_getGlobalVariable(java.lang.String variable)
variable
- String, the name of the global variable.java.lang.IllegalStateException
- if the value is NOT present or attainable.public static void js_setGlobalBoolVariable(java.lang.String variable, boolean onOrOff)
variable
- String, the name of the global variable.onOrOff
- boolean, the value to setjs_setGlobalVariable(String, String)
public static void js_setGlobalVariable(java.lang.String variable, java.lang.String value)
variable
- String, the name of the global variable.value
- String, the value to setprotected static void js_initialize()
public static void js_initError() throws SeleniumPlusException
JavaScriptFunctions.SAFS_JAVASCRIPT_GLOBAL_ERROR_CODE_VAR
,JavaScriptFunctions.ERROR_CODE_NOT_SET
. JavaScriptFunctions.SAFS_JAVASCRIPT_GLOBAL_ERROR_OBJECT_VAR
to undefined.SeleniumPlusException
public static void js_cleanError() throws SeleniumPlusException
JavaScriptFunctions.SAFS_JAVASCRIPT_GLOBAL_ERROR_CODE_VAR
,JavaScriptFunctions.ERROR_CODE_NOT_SET
. JavaScriptFunctions.SAFS_JAVASCRIPT_GLOBAL_ERROR_OBJECT_VAR
, reset it to undefined.SeleniumPlusException
public static int js_getErrorCode() throws SeleniumPlusException
JavaScriptFunctions.SAFS_JAVASCRIPT_GLOBAL_ERROR_CODE_VAR
.SeleniumPlusException
public static void js_setErrorCode(int error) throws SeleniumPlusException
JavaScriptFunctions.SAFS_JAVASCRIPT_GLOBAL_ERROR_CODE_VAR
SeleniumPlusException
public static java.lang.Object js_getErrorObject() throws SeleniumPlusException
JavaScriptFunctions.SAFS_JAVASCRIPT_GLOBAL_ERROR_OBJECT_VAR
.SeleniumPlusException
public static void js_setErrorObject(java.lang.String errorMessage) throws SeleniumPlusException
JavaScriptFunctions.SAFS_JAVASCRIPT_GLOBAL_ERROR_OBJECT_VAR
SeleniumPlusException
public static boolean highlightThenClear(org.openqa.selenium.WebElement webelement, int duration)
webelement
- WebElement, the web element to highlight.duration
- int, how long in millisecond the red rectangle will stay.highlight(WebElement)
,
clearHighlight()
public static boolean highlight(java.lang.String idOrNameOrXpath)
idOrNameOrXpath
- String, the id or name or xpath of web element to highlight.public static boolean highlight(org.openqa.selenium.WebElement webelement)
clearHighlight()
.webelement
- WebElement, the web element to highlight.clearHighlight()
public static boolean clearHighlight()
highlight(String)
highlight(WebElement)
, normally you don't need to call this methodhighlight(String)
,
highlight(WebElement)
public static boolean isVisible(org.openqa.selenium.WebElement element) throws SeleniumPlusException
element
- WebElementSeleniumPlusException
- if the WebElement is nullisDisplayed(WebElement)
public static boolean isDisplayed(org.openqa.selenium.WebElement element) throws SeleniumPlusException
element
- WebElement, the element to check.SeleniumPlusException
- if the WebElement is null or is staleisVisible(WebElement)
public static boolean isStale(org.openqa.selenium.WebElement element) throws SeleniumPlusException
element
- WebElement, the WebElement to detect.SeleniumPlusException
- if the element is null.public static java.lang.String addJavaScriptEventListener(org.openqa.selenium.WebElement element, java.lang.String eventName, SearchObject.GenericJSEventListener listener) throws SeleniumPlusException
element
- WebElement, the element to which the listener will be added.eventName
- String, event name to attach this listener.listener
- GenericJSEventListener, the listener to respond to fired-event.SeleniumPlusException
public static void removeJavaScriptEventListener(org.openqa.selenium.WebElement element, java.lang.String eventName, java.lang.String listenerID) throws SeleniumPlusException
String listenerID = null; try{ listenerID = addJavaScriptEventListener(element, eventName, listener); }catch(Exception e){ }finally{ if(listenerID!=null) removeJavaScriptEventListener(element, eventName, listenerID); }
element
- WebElement, the element from which the listener will be removed.eventName
- String, event name to detach a listener.String,
- the ID of this listener, used to remove a listener.SeleniumPlusException
public static java.lang.Object executeJavaScriptOnWebElement(java.lang.String script, org.openqa.selenium.WebElement webelement, java.lang.Object... args) throws SeleniumPlusException
script
- String, the javascript function to execute. Its first parameter is always DOM object.webelement
- WebElement, used to find the DOM Object to operate.args
- Object[], the extra parameters used by the javascript function, from SECOND parameter.SeleniumPlusException
public static java.lang.Object executeScript(java.lang.String script, java.lang.Object... args) throws SeleniumPlusException
SeleniumPlusException
JavascriptExecutor.executeScript(String, Object...)
,
executeScript(boolean, String, Object...)
public static java.lang.Object executeAsyncScript(java.lang.String script, java.lang.Object... args) throws SeleniumPlusException
SeleniumPlusException
JavascriptExecutor.executeAsyncScript(String, Object...)
,
executeScript(boolean, String, Object...)
protected static void setJsExecutionDelay(int milliseconds)
DEFAULT_JS_EXECUTION_DELAY
after a special javascript call,
otherwise the performance of the SeleniumPlus framework will be slowed down.milliseconds
- int, the milliseconds to delay the javascript execution.executeScript(boolean, String, Object...)
public static int getJsExecutionDelay()
executeScript(boolean, String, Object...)
public static java.lang.Object executeScript(boolean synch, java.lang.String script, java.lang.Object... args) throws SeleniumPlusException
It is user's responsibility to set javascript global errorcode and errormessage in his javascript code, user can callJavaScriptFunctions.setJSErrorCode(int)
JavaScriptFunctions.setJSErrorObject(String)
for example, seeJavaScriptFunctions.SAP#sap_m_List_getItems(boolean)
.
SeleniumPlusException
- if there is no appropriate JavascriptExecutor to use.JavascriptExecutor.executeScript(String, Object...)
,
JavascriptExecutor.executeAsyncScript(String, Object...)
public static org.openqa.selenium.JavascriptExecutor getJS() throws SeleniumPlusException
SeleniumPlusException
public static void refreshJSExecutor() throws SeleniumPlusException
lastUsedWD
to refresh the lastJS
.SeleniumPlusException
- if the lastUsedWD
cannot be casted to a JavascriptExecutorpublic static void checkNotNull(java.lang.Object object) throws SeleniumPlusException
object
- ObjectSeleniumPlusException
- will be thrown out with SeleniumPlusException.CODE_OBJECT_IS_NULL
if the object is null.public static java.lang.String getCssSelector(java.lang.String type, org.openqa.selenium.WebElement element)
type
- String, the type of the css selector.element
- WebElement, the WebElement from which a css selector will be generated.static java.lang.String getDescription(org.openqa.selenium.WebElement element)
element
- WebElementpublic static java.lang.Object getWebElementProperty(org.openqa.selenium.WebElement element, java.lang.String property)
element
- WebElementproperty
- String property to retrieve.public static org.openqa.selenium.WebElement getParentWebElement(org.openqa.selenium.WebElement element)
element
- WebElementstatic boolean checkCSSClassName(org.openqa.selenium.WebElement element, java.lang.String prefix, java.lang.String separator)
element
- WebElement, The selenium web elementprefix
- String, the prefix of the css class nameseparator
- String, the separator in the css class name, normally its a ' 'public static boolean isSAPDomain(org.openqa.selenium.WebElement element) throws SeleniumPlusException
element
- SeleniumPlusException
public static boolean isDojoDomain(org.openqa.selenium.WebElement element) throws SeleniumPlusException
element
- SeleniumPlusException
@Deprecated public static java.lang.String generateUniqueName(java.lang.String prefix)
prefix
- String, the prefix of the unique namepublic static void resetXPathObjectCache()
This should be called by external routines getting ready to process an entire page of web elements to avoid processing the same parent nodes many times. This is strictly for performance reasons.
The routine should be called both BEFORE and AFTER the processing of nodes with the recursive generateGenericXPath routine.
generateFullGenericXPath(WebElement)
public static java.lang.String generateFullGenericXPath(org.openqa.selenium.WebElement element)
Uses generateGenericXPath for each node in the hierarchy.
A caller getting ready to process many web elements--or even just one-should ALWAYS call resetXPathObjectCache before processing that first element and after processing the last element.
element
- generateGenericXPath(WebElement)
,
resetXPathObjectCache()
public static java.lang.String generateGenericXPath(org.openqa.selenium.WebElement element)
Currently tries to differentiate the tag name by id, title, or class.
Examples:
if none of those have valid values, then only the tag name is returned. In that case, we check to see if it is the Nth sibling of the same tag type and add that, if needed.
element
- public static java.lang.String generateSAFSFrameRecognition(java.lang.String framexpath)
Currently tries to differentiate the tag name by id, name, or index.
framexpath
- from generateGenericXPathpublic static boolean switchWindow(java.lang.String title, boolean... optionals) throws SeleniumPlusException
lastUsedWD
, lastJS
may probably get changed.title
- String, the title of the window to switch to. It can be a normal string, a regexp string or a wildcard string.
If it is regexp/wildcard string, the optional parameters will be ignored.optionals
- boolean[]
SeleniumPlusException
public static boolean switchWindow(java.lang.String title, int expectedMatchIndex, boolean... optionals) throws SeleniumPlusException
lastUsedWD
, lastJS
may probably get changed.title
- String, the title of the window to switch to. It can be a normal string, a regexp string or a wildcard string.
If it is regexp/wildcard string, the optional parameters will be ignored.expectedMatchIndex
- int, the index of matched window if multiple windows match. These windows are ordered according to
their title alphabet order. It is 1-based index and should be bigger than MATCHED_ZERO_TIMES
optionals
- boolean[]
SeleniumPlusException
public static boolean switchWindow(java.lang.String browserID, java.lang.String title, boolean... optionals) throws SeleniumPlusException
lastUsedWD
, lastJS
may probably get changed.browserID
- String, the browser ID when calling #startBrowser(String, String, String, int, boolean)
title
- String, the title of the window to switch to. It can be a normal string, a regexp string or a wildcard string.
If it is regexp/wildcard string, the optional parameters will be ignored.optionals
- boolean[]
SeleniumPlusException
public static int switchWindow(java.lang.String browserID, java.lang.String title, int expectedMatchIndex, boolean... optionals) throws SeleniumPlusException
lastUsedWD
, lastJS
may probably get changed.browserID
- String, the browser ID when calling #startBrowser(String, String, String, int, boolean)
title
- String, the title of the window to switch to. It can be a normal string, a regexp string or a wildcard string.
If it is regexp/wildcard string, the optional parameters will be ignored.expectedMatchIndex
- int, the index of matched window if multiple windows match. These windows are ordered according to
their title alphabet order. It is 1-based index and should be bigger than MATCHED_ZERO_TIMES
optionals
- boolean[]
SeleniumPlusException
protected static java.lang.String getThrowableMessages(java.lang.Throwable th)
Copyright © SAS Institute. All Rights Reserved.