public class SeleniumGUIUtilities extends DDGUIUtilities
DDGUIUtilities
Modifier and Type | Field and Description |
---|---|
DocumentParser |
domParser |
static java.util.regex.Pattern |
FRAME_PATTERN |
boolean |
frameSwitched |
java.lang.String |
UNNAMED_WINDOW |
appmaps, DEBUG_MESSAGE, FAILED_MESSAGE, FAILED_OK_MESSAGE, GENERIC_MESSAGE, log, PASSED_MESSAGE, trdata, WARNING_MESSAGE, WARNING_OK_MESSAGE
staf
Constructor and Description |
---|
SeleniumGUIUtilities()
No-argument constructor.
|
SeleniumGUIUtilities(STAFHelper helper,
LogUtilities log)
Constructor providing the STAFHelper and LogUtilities needed for
proper operation.
|
SeleniumGUIUtilities(STAFHelper helper,
TestRecordData data,
LogUtilities log)
Constructor providing the STAFHelper, LogUtilities, and TestRecordData for proper operation.
|
Modifier and Type | Method and Description |
---|---|
void |
clearFramesCache() |
java.util.List<?> |
extractListItems(java.lang.Object obj,
java.lang.String countProp,
java.lang.String itemProp)
Extract items from a List or Array type of object property.
|
Tree |
extractMenuBarItems(java.lang.Object obj)
Extract a menu hierarchy from a MenuBar pseudo-object reference.
|
Tree |
extractMenuItems(java.lang.Object obj)
Extract a menu hierarchy from a object.
|
java.lang.Object |
findPropertyMatchedChild(java.lang.Object obj,
java.lang.String property,
java.lang.String bench,
boolean exactMatch)
Attempt to locate a child object based on a matching property value.
|
java.lang.String[] |
getAllWindowNames(com.thoughtworks.selenium.Selenium selenium)
Wraps Selenium.getAllWindowNames to handle Selenium defect.
|
java.lang.String[] |
getAllXPaths(java.lang.String tag,
com.thoughtworks.selenium.Selenium selenium)
Gets all the xpaths for a certain html tag
|
java.lang.String |
getAttribute(com.thoughtworks.selenium.Selenium selenium,
java.lang.String xpath,
java.lang.String attribute)
Purpose: Return the value of attribute for an element indicated by xpath
Note: This method will try to DocumentParser to get the value
If it can not get the value, it will try the selenium's API getAttribute. |
java.util.HashMap |
getAttributes(com.thoughtworks.selenium.Selenium selenium,
java.lang.String xpath)
Purpose: Return the attributes for an element indicated by xpath
Note: This method will try to DocumentParser to get the properties
|
protected java.awt.Rectangle |
getComponentBounds(SGuiObject o,
com.thoughtworks.selenium.Selenium selenium)
Returns the bounds of a component as a Rectangle object
|
protected java.awt.Rectangle |
getComponentBounds(java.lang.String xpath,
com.thoughtworks.selenium.Selenium selenium)
Returns the absolute bounds of a component on the screen as a Rectangle object
|
DocumentParser |
getDocumentParser(com.thoughtworks.selenium.Selenium selenium)
Purpose: Return a HtmlDoParser, if not exist, create a new one.
|
protected java.lang.String |
getFramePath(java.lang.String xpath) |
SGuiObject |
getGuiObject(java.lang.String recString,
com.thoughtworks.selenium.Selenium selenium,
java.lang.String windowId)
Returns the xpath of the component represented by a robot recognition string
|
java.lang.String |
getListItem(java.lang.Object obj,
int i,
java.lang.String itemProp)
Get a single list item from a List or Array type of object property.
|
java.lang.String |
getProperty(com.thoughtworks.selenium.Selenium selenium,
java.lang.String xpath,
java.lang.String attribute)
Return the value of a specific attribute/property
|
SGuiObject |
getTestObject(java.lang.String mapname,
java.lang.String windowName,
java.lang.String childName,
boolean ignoreCache)
Gets the object defined by the windowName and childName
|
SGuiObject |
getWindowIdFromTitle(com.thoughtworks.selenium.Selenium selenium,
java.lang.String winRec)
Get's the window's id and returns it in the form of an SGuiObject
|
protected DocumentParser |
initDocumentParser(com.thoughtworks.selenium.Selenium selenium)
Purpose: Create a new HtmlDoParser, it will replace the older one.
|
static java.util.regex.Matcher |
matchPattern(java.util.regex.Pattern pattern,
java.lang.String xpath) |
void |
maximizeWindow(java.lang.String winRec)
Uses ComponentFunctions.dll to maximize the window with the given recognition string.
|
boolean |
maximizeWindow(java.lang.String windowId,
com.thoughtworks.selenium.Selenium selenium)
Uses Selenium to maximize the window with the given window id.
Note: The window can't be resotre after it is maximized by this method. |
void |
minimizeWindow(java.lang.String winRec)
Uses ComponentFunctions.dll to maximize the window with the given recognition string.
|
protected java.lang.String |
navigateFrames(java.lang.String xpath,
com.thoughtworks.selenium.Selenium selenium)
Selects any frames that are part of the xpath and
returns the last component's xpath |
protected HtmlFrameComp |
navigateFrames(java.lang.String url,
java.lang.String xpath,
com.thoughtworks.selenium.Selenium selenium)
Selects any frames that are part of the xpath and
returns the last Frame preceding final component xpath |
protected HtmlFrameComp |
navigateFrames(java.lang.String url,
java.lang.String xpath,
com.thoughtworks.selenium.Selenium selenium,
java.awt.Rectangle boundsOut)
Selects any frames that are part of the xpath and
returns the last Frame preceding final component xpath |
static java.lang.String |
normalizeXPath(java.lang.String xPath) |
void |
restoreWindow(java.lang.String winRec)
Uses ComponentFunctions.dll to maximize the window with the given recognition string.
|
void |
selectTopFrame(com.thoughtworks.selenium.Selenium selenium)
Selects the top frame if its not already selected
|
boolean |
selectWindow(com.thoughtworks.selenium.Selenium selenium,
java.lang.String id,
long timeout)
selects a window to send future commands to
|
int |
setActiveWindow(java.lang.String appMapName,
java.lang.String windowName,
java.lang.String compName)
Attempts to "activate" or give focus to the specified window/object via the remote
AUT JVM proxies.
|
boolean |
setWindowFocus(java.lang.String winRec)
Uses ComponentFunctions.dll to focus the window with the given recognition string.
|
boolean |
setWindowFocus(java.lang.String windowId,
com.thoughtworks.selenium.Selenium selenium)
Uses Selenium to focus the window with the given window id.
|
int |
waitForObject(java.lang.String appMapName,
java.lang.String windowName,
java.lang.String compName,
long secTimeout)
Uses the Application Map caching mechanism provided by the superclass.
|
clearAllAppMapCaches, clearAppMapCache, createAppMapInstance, getAppMap, getLogUtilities, getTestRecordData, isAppMapRegistered, openAppMap, registerAppMap, registerAppMap, setLogUtilities, setTestRecordData
getSTAFHelper, setSTAFHelper
public static final java.util.regex.Pattern FRAME_PATTERN
public boolean frameSwitched
public java.lang.String UNNAMED_WINDOW
public DocumentParser domParser
public SeleniumGUIUtilities()
DDGUIUtilities.DDGUIUtilities()
public SeleniumGUIUtilities(STAFHelper helper, LogUtilities log)
helper
- The STAFHelper for performing STAF requests.log
- the LogUtilities for logging.STAFHelper
,
LogUtilities
public SeleniumGUIUtilities(STAFHelper helper, TestRecordData data, LogUtilities log)
helper
- The STAFHelper for performing STAF requests.data
- the TestRecordData generally an instanceof STestRecordHelper.log
- the LogUtilities for logging.STAFHelper
,
STestRecordHelper
,
LogUtilities
public int waitForObject(java.lang.String appMapName, java.lang.String windowName, java.lang.String compName, long secTimeout) throws SAFSObjectNotFoundException
waitForObject
in class DDGUIUtilities
appMapName
- the name/ID of the App Map currently in use.windowName
- the name/ID of the window as predefined in the App Map.compName
- the name/ID of the child component of the window as predefined
in the App Map.secTimeout
- the number of seconds allowed to located the object before a
SAFSObjectNotFoundException is thrown.SAFSObjectNotFoundException
- if specified parent or child cannot be found.DDGUIUtilities.waitForObject(String,String,String,long)
public SGuiObject getTestObject(java.lang.String mapname, java.lang.String windowName, java.lang.String childName, boolean ignoreCache)
mapName
- the name/ID of the App Map currently in use.windowName
- the name/ID of the window as predefined in the App Map.childName
- the name/ID of the child component of the window as predefined in the App Map.ignoreCache
- if true, try getting the component from the appmappublic boolean selectWindow(com.thoughtworks.selenium.Selenium selenium, java.lang.String id, long timeout)
selenium
- Current Selenium objectid
- windowId--can be nulltimeout
- how long to wait for the window in secondspublic java.lang.String[] getAllWindowNames(com.thoughtworks.selenium.Selenium selenium)
public SGuiObject getWindowIdFromTitle(com.thoughtworks.selenium.Selenium selenium, java.lang.String winRec)
selenium
- current selenium objectwinRec
- window recognition stringpublic int setActiveWindow(java.lang.String appMapName, java.lang.String windowName, java.lang.String compName) throws SAFSObjectNotFoundException
setActiveWindow
in class DDGUIUtilities
appMapName
- name of AppMap used to lookup component.windowName
- name of Window in AppMap.compName
- name of Window Component in AppMap.
If the Window IS the desired Component, then both windowName
and compName will be the same.SAFSObjectNotFoundException
- if the specified component cannot be found.DDGUIUtilities.setActiveWindow(String,String,String)
public void selectTopFrame(com.thoughtworks.selenium.Selenium selenium)
selenium
- Current selenium objectpublic java.lang.String getProperty(com.thoughtworks.selenium.Selenium selenium, java.lang.String xpath, java.lang.String attribute)
selenium
- current Selenium objectxpath
- Selenium XPATH to desired elementattribute
- case-sensitive property namepublic SGuiObject getGuiObject(java.lang.String recString, com.thoughtworks.selenium.Selenium selenium, java.lang.String windowId)
recString
- robot recognition stringselenium
- current selenium objectwindowId
- window containing the objectpublic static java.lang.String normalizeXPath(java.lang.String xPath)
public static java.util.regex.Matcher matchPattern(java.util.regex.Pattern pattern, java.lang.String xpath)
protected java.lang.String getFramePath(java.lang.String xpath)
protected java.lang.String navigateFrames(java.lang.String xpath, com.thoughtworks.selenium.Selenium selenium)
xpath
- xpath of the frames and component that needs to be interacted withselenium
- current selenium objectprotected HtmlFrameComp navigateFrames(java.lang.String url, java.lang.String xpath, com.thoughtworks.selenium.Selenium selenium)
url
- from where the xpath will be parsed, that is, the page indicated by url
should contain the element described by xpathxpath
- xpath of the frames and component that needs to be interacted withselenium
- current selenium objectprotected HtmlFrameComp navigateFrames(java.lang.String url, java.lang.String xpath, com.thoughtworks.selenium.Selenium selenium, java.awt.Rectangle boundsOut)
url
- from where the xpath will be parsed, that is, the page indicated by url
should contain the element described by xpathxpath
- xpath of the frames and component that needs to be interacted withselenium
- current selenium objectboundsOut
- object that will contain the bounds of the component after its foundprotected java.awt.Rectangle getComponentBounds(SGuiObject o, com.thoughtworks.selenium.Selenium selenium)
o
- object describing the componentselenium
- current selenium objectprotected java.awt.Rectangle getComponentBounds(java.lang.String xpath, com.thoughtworks.selenium.Selenium selenium)
xpath
- xpath string describing the componentselenium
- current selenium objectprotected DocumentParser initDocumentParser(com.thoughtworks.selenium.Selenium selenium)
selenium
- public DocumentParser getDocumentParser(com.thoughtworks.selenium.Selenium selenium)
selenium
- public java.lang.String getAttribute(com.thoughtworks.selenium.Selenium selenium, java.lang.String xpath, java.lang.String attribute)
selenium
- The instance of Seleniumxpath
- Xpath to represent the element in html pageattribute
- The name of attributeDocumentParser.getAttribute(String, String, String)
public java.util.HashMap getAttributes(com.thoughtworks.selenium.Selenium selenium, java.lang.String xpath)
selenium
- The instance of Seleniumxpath
- Xpath to represent the element in html pageDocumentParser.getAttributes(String, String)
public java.lang.String[] getAllXPaths(java.lang.String tag, com.thoughtworks.selenium.Selenium selenium)
tag
- html tag of the components to get the xpaths forselenium
- current selenium objectpublic java.util.List<?> extractListItems(java.lang.Object obj, java.lang.String countProp, java.lang.String itemProp) throws SAFSException
DDGUIUtilities
extractListItems
in class DDGUIUtilities
SAFSException
public Tree extractMenuBarItems(java.lang.Object obj) throws SAFSException
DDGUIUtilities
extractMenuBarItems
in class DDGUIUtilities
SAFSException
public Tree extractMenuItems(java.lang.Object obj) throws SAFSException
DDGUIUtilities
extractMenuItems
in class DDGUIUtilities
SAFSException
public java.lang.Object findPropertyMatchedChild(java.lang.Object obj, java.lang.String property, java.lang.String bench, boolean exactMatch) throws SAFSObjectNotFoundException
DDGUIUtilities
findPropertyMatchedChild
in class DDGUIUtilities
obj
- -- the pseudo-object reference whose children will be evaluated.
property
- -- the property of each child that will be evaluated. The property is
expected to be one that can successfully return a value
cast as type String.
bench
- -- the benchmark value for the property to be used in comparisons.
exactMatch
- -- if true, an exact case-sensitive match of the bench value
provided is required to signal a match.SAFSObjectNotFoundException
- if no matching child object is found.
StringUtils.isCaseContainsMatch(String,String,boolean)
public java.lang.String getListItem(java.lang.Object obj, int i, java.lang.String itemProp) throws SAFSException
DDGUIUtilities
getListItem
in class DDGUIUtilities
SAFSException
public boolean setWindowFocus(java.lang.String winRec)
winRec
- window to be focusedpublic boolean setWindowFocus(java.lang.String windowId, com.thoughtworks.selenium.Selenium selenium)
windowId
- window's name or titleselenium
- the instance of Selenium objectpublic boolean maximizeWindow(java.lang.String windowId, com.thoughtworks.selenium.Selenium selenium)
windowId
- window's name or titleselenium
- the instance of Selenium objectpublic void maximizeWindow(java.lang.String winRec)
winRec
- window to be maximizepublic void minimizeWindow(java.lang.String winRec)
winRec
- window to be maximizepublic void restoreWindow(java.lang.String winRec)
winRec
- window to be maximizepublic void clearFramesCache()
Copyright © SAS Institute. All Rights Reserved.