public class WDLibrary extends SearchObject
Modifier and Type | Class and Description |
---|---|
static class |
WDLibrary.RBT
This class represents a Robot, which can do work locally (thru local org.safs.robot.Robot) or remotely (thru a RMI agent).
|
static class |
WDLibrary.WD_XMLHttpRequest
Implements
XMLHttpRequest , through WDLibrary to execute javascript
JavaScriptFunctions.sendHttpRequest(Map) to handle HTTP Request. |
SearchObject.BrowserWindow, SearchObject.DefaultJSEventListener, SearchObject.DOJO, SearchObject.FrameElement, SearchObject.GenericJSEventListener, SearchObject.HTML, SearchObject.SAP, SearchObject.SwitchFramesResults
Modifier and Type | Field and Description |
---|---|
static WDLibrary.WD_XMLHttpRequest |
AJAX
An instance of WD_XMLHttpRequest, used to send HTTP request.
|
protected static boolean |
debug |
static int |
DEFAULT_TIMEOUT_WAIT_ALERT
The timeout in seconds to wait for the alert's presence.
The default value is 2 seconds. |
static int |
DEFAULT_TIMEOUT_WAIT_CLICK
2 seconds to wait for a click action finished on page.
|
static int |
DEFAULT_TIMEOUT_WAIT_ROBOT_CLICK
10 seconds to wait for a Robot click action finished on page.
|
static boolean |
DEFAUT_AUTOSCROLL
'true', the default value for scrolling the web-element into view automatically before performing click ation on it.
|
static boolean |
enableClickListenerFailures
Default true.
|
protected static InputKeysParser |
keysparser |
static int |
MOUSE_BUTTON_LEFT
InputEvent.BUTTON1_MASK |
static int |
MOUSE_BUTTON_MIDDLE
InputEvent.BUTTON2_MASK |
static int |
MOUSE_BUTTON_RIGHT
InputEvent.BUTTON3_MASK |
static int |
TIMEOUT_NOWAIT
0, means no waiting.
|
static int |
TIMEOUT_WAIT_FOREVER
-1, means wait for ever
|
static int |
timeoutCheckAlertForClick
time (in seconds) to check if an Alert is present on page before clicking.
|
static int |
timeoutWaitAlert
time (in seconds) to wait for an Alert appear on page.
|
static int |
timeoutWaitClick
time (in seconds) to wait for a click action finished on page.
|
static int |
timeoutWaitRobotClick
time (in seconds) to wait for a Robot click action finished on page.
|
assignSeparator, childSeparator, CSS_CLASS_DOJO_DIJIT_PREFIX, CSS_CLASS_SAP_PREFIX, CSS_CLASS_SEPARATOR, CSS_SELECTOR_BY_CLASSNAME, CSS_SELECTOR_BY_ID, DEFAULT_IGNORE_CASE, DEFAULT_JS_EXECUTION_DELAY, DEFAULT_JS_TIMEOUT, DEFAULT_PARTIAL_MATCH, DOMAIN_DOJO, DOMAIN_HTML, DOMAIN_SAP, escapeChar, IGNORED_NONUI_TAGS, INVALID_INDEX, jsEventListenerMap, jsEventListenerWaitingThreadMap, lastBrowserWindow, lastFrame, lastJS, lastUsedWD, lastVisitedURL, MATCHED_ONE_TIME, MATCHED_ZERO_TIMES, propertySeparator, qulifierSeparator, SEARCH_CRITERIA_CLASS, SEARCH_CRITERIA_CLASS_CONTAINS, SEARCH_CRITERIA_CONTAINS_SUFFIX, SEARCH_CRITERIA_CSS, SEARCH_CRITERIA_FRAMEID, SEARCH_CRITERIA_FRAMEINDEX, SEARCH_CRITERIA_FRAMENAME, SEARCH_CRITERIA_FRAMEXPATH, SEARCH_CRITERIA_ID, SEARCH_CRITERIA_IFRAMEID, SEARCH_CRITERIA_INDEX, SEARCH_CRITERIA_ITEMINDEX, SEARCH_CRITERIA_LINK, SEARCH_CRITERIA_NAME, SEARCH_CRITERIA_PARTIALLINK, SEARCH_CRITERIA_PATH, SEARCH_CRITERIA_PROPERTY, SEARCH_CRITERIA_PROPERTY_CONTAINS, SEARCH_CRITERIA_TAG, SEARCH_CRITERIA_TEXT, SEARCH_CRITERIA_TITLE, SEARCH_CRITERIA_TYPE, SEARCH_CRITERIA_XPATH, TAG_FRAME, TAG_IFRAME, TEXT_VALUE_ATTRIBUTES, XPATH_CHILD_SEPARATOR
Constructor and Description |
---|
WDLibrary() |
Modifier and Type | Method and Description |
---|---|
static void |
alignToBottom(org.openqa.selenium.WebElement element)
Align the bottom of webelement to the bottom of browser.
|
static void |
alignToTop(org.openqa.selenium.WebElement element)
Align the top of webelement to the top of browser.
|
static void |
altLeftDrag(org.openqa.selenium.WebElement we,
java.awt.Point start,
java.awt.Point end)
Perform a left-drag from start point to end point relative to webelement (LeftUp corner)
with the "ALT" key pressed during the drag.
|
static java.awt.image.BufferedImage |
captureBrowserArea(java.awt.Rectangle rectangle)
Capture the image on browser according to the rectangle relative to the browser.
|
static void |
captureScreen(java.lang.String image)
Capture entire current HTML page
|
static void |
captureScreen(org.openqa.selenium.WebElement we,
java.lang.String imgName,
java.lang.String fileformat)
Capture component image
|
static void |
checkKnownIssue(java.lang.String keyword)
Check some known issue for a certain keyword.
|
static void |
clearClipboard()
Clear the clipboard on local machine or on machine where the RMI server is running.
|
static void |
click(org.openqa.selenium.WebElement clickable,
org.openqa.selenium.Keys specialKey,
java.lang.String... optional)
Click(Mouse Left Button) the WebElement at center with a special key pressed.
|
static void |
click(org.openqa.selenium.WebElement clickable,
java.awt.Point offset,
org.openqa.selenium.Keys specialKey,
int mouseButtonNumber,
java.lang.String... optional)
Click the WebElement at a certain coordination with a special key pressed.
Firstly it will try to get webelement's location and use Robot to click. |
static void |
click(org.openqa.selenium.WebElement clickable,
java.awt.Point offset,
java.lang.String... optional)
Click(Mouse Left Button) the WebElement at a certain coordination.
|
static void |
click(org.openqa.selenium.WebElement clickable,
java.lang.String... optional)
Click(Mouse Left Button) - Click on WebElement or WebDriver object at the center
|
static boolean |
clickUnverified(org.openqa.selenium.WebElement component,
java.awt.Point offset,
java.lang.String... optional)
Click a component with an offset.
|
static void |
closeAlert(boolean accept,
java.lang.String... optionals)
Close the Alert-Modal-Dialog associated with a certain browser identified by ID.
It will get the cached webdriver according to the browser's id, and close the 'alert' through that webdriver. Note:This API will NOT change the current WebDriver. |
static void |
closeBrowser()
Close the Browser/WebDriver associated with the last WebElement accessed.
|
(package private) static java.lang.CharSequence |
convertToCharacter(RobotKeyEvent event)
Convert a SAFS RobotKeyEvent to a standard CharSequence character.
|
static org.openqa.selenium.Keys |
convertToKeys(int keycode)
Convert a Java KEYCODE to a Selenium WebDriver Keys Enum
|
static org.openqa.selenium.Keys |
convertToKeys(RobotKeyEvent event)
Convert a SAFS RobotKeyEvent to a Selenium WebDriver Keys Enum
|
static void |
ctrlAltLeftDrag(org.openqa.selenium.WebElement we,
java.awt.Point start,
java.awt.Point end)
Perform a left-drag from start point to end point relative to webelement (LeftUp corner)
with the "CONTROL" and "ALT" key pressed during the drag.
|
static void |
ctrlLeftDrag(org.openqa.selenium.WebElement we,
java.awt.Point start,
java.awt.Point end)
Perform a left-drag from start point to end point relative to webelement (LeftUp corner)
with the "CONTROL" key pressed during the drag.
|
static void |
ctrlShiftLeftDrag(org.openqa.selenium.WebElement we,
java.awt.Point start,
java.awt.Point end)
Perform a left-drag from start point to end point relative to webelement (LeftUp corner)
with the "CONTROL" and "SHIFT" key pressed during the drag.
|
static void |
doubleClick(org.openqa.selenium.WebElement clickable,
org.openqa.selenium.Keys specialKey,
java.lang.String... optional)
Double-Click(Mouse Left Button) the WebElement at the center with a special key pressed.
|
static void |
doubleClick(org.openqa.selenium.WebElement clickable,
java.awt.Point offset,
org.openqa.selenium.Keys specialKey,
int mouseButtonNumber,
java.lang.String... optional)
Double-Click the WebElement at a certain coordination with a special key pressed.
Firstly it will try to get webelement's location and use Robot to double click. |
static void |
doubleClick(org.openqa.selenium.WebElement clickable,
java.awt.Point offset,
java.lang.String... optional)
Double-Click(Mouse Left Button) the WebElement at a certain coordination.
|
static void |
doubleClick(org.openqa.selenium.WebElement clickable,
java.lang.String... optional)
Double-Click(Mouse Left Button) the WebElement at the center.
|
static void |
fireMouseEvent(MouseEvent event)
Attempts to fire (dispatchEvent) a MouseEvent.
|
static boolean |
focus(org.openqa.selenium.WebElement element)
Attempt to SetFocus on the WebElement.
|
static java.lang.String |
getBrowserName() |
static java.lang.String |
getBrowserName(org.openqa.selenium.WebDriver driver) |
static java.lang.String |
getBrowserVersion() |
static org.openqa.selenium.WebDriver |
getBrowserWithID(java.lang.String id)
Retrieves the WebDriver/Browser with the given id.
|
static org.openqa.selenium.WebDriver |
getBrowserWithTitle(java.lang.String title)
Retrieves the WebDriver/Browser with the given title.
|
static java.lang.Object |
getClipboard(java.awt.datatransfer.DataFlavor dataFlavor)
Get the content from the clipboard on local machine or on machine where the RMI server is running.
|
static java.util.Map<java.lang.String,java.lang.String> |
getCssValues(org.openqa.selenium.WebElement element)
Get css values of the object
|
static int |
getDelayBetweenKeystrokes()
Gets the current delay in milliseconds between Robot keystrokes for both local and remote servers.
|
static java.lang.String |
getDriverVersion() |
static java.awt.Point |
getElementOffsetScreenLocation(org.openqa.selenium.WebElement element,
java.lang.String offsetX,
java.lang.String offsetY)
Given the element, and the (offsetX, offsetY) relative to element.
|
static java.awt.Point |
getLocation(org.openqa.selenium.WebElement webelement)
Get the web-element's location relative to the browser.
|
static java.awt.Point |
getLocation(org.openqa.selenium.WebElement webelement,
boolean useOnPageFirstly)
Get the web-element's location relative to the browser client area.
|
static java.lang.String |
getPlatform() |
static java.util.Map<java.lang.String,java.lang.Object> |
getProperties(org.openqa.selenium.WebElement element)
Retrieve all properties of an element--attributes, css values, property fields and certain property methods.
|
static java.lang.String |
getProperty(org.openqa.selenium.WebElement element,
java.lang.String property)
get the value of a property.
|
static java.awt.Rectangle |
getRectangleOnScreen(org.openqa.selenium.WebElement we)
Get the screen rectangle for a WebElement object.
|
static java.awt.Point |
getScreenLocation(org.openqa.selenium.WebElement webelement)
Get the absolute coordination on the screen of the webelement object.
Hope Selenium will give this function one day! |
static com.sebuilder.interpreter.Script |
getSeleniumBuilderScript(java.lang.String path)
Load a SeBuilder JSON Script from the provided path so it can be started or run.
|
static int |
getTimeoutCheckAlertForClick() |
static com.sebuilder.interpreter.webdriverfactory.WebDriverFactory |
getWebDriverAsWebDriverFactory() |
static void |
highlightElement(org.openqa.selenium.WebElement element)
Deprecated.
it is replaced by
SearchObject.highlight(WebElement) . |
static void |
inputChars(org.openqa.selenium.WebElement we,
java.lang.String keystrokes)
Does NOT clear any existing text in the control, but does attempt to insure the window/control has focus.
|
static void |
inputKeys(org.openqa.selenium.WebElement we,
java.lang.String keystrokes)
Does NOT clear any existing text in the control, but does attempt to insure the window/control has focus.
|
static void |
inputKeysSAFS2Selenium(org.openqa.selenium.WebElement we,
java.lang.String keystrokes)
Does NOT clear any existing text in the control, but does attempt to insure the window/control has focus.
|
static boolean |
inside(org.openqa.selenium.WebElement element,
java.awt.Point p)
Check if the point is inside of the boundary of WebElement.
|
static boolean |
isAlertPresent(java.lang.String... optionals)
Test the presence of Alert-Modal-Dialog associated with a certain browser identified by ID.
It will get the cached webdriver according to the browser's id, and get the 'alert' through that webdriver. Note:This API will NOT change the current WebDriver. |
static boolean |
isChrome(org.openqa.selenium.WebDriver driver) |
static boolean |
isFireFox(org.openqa.selenium.WebDriver driver) |
static boolean |
isHtmlUnit(org.openqa.selenium.WebDriver driver) |
static boolean |
isInternetExplorer(org.openqa.selenium.WebDriver driver) |
static boolean |
isLeftMouseButton(int buttonNumber) |
static boolean |
isLocationInBounds(org.openqa.selenium.Point p,
org.openqa.selenium.Dimension bounds)
check if the point p locates in the Dimension.
|
static boolean |
isMiddleMouseButton(int buttonNumber) |
static boolean |
isPointInBounds(org.openqa.selenium.Point p,
org.openqa.selenium.Dimension bounds)
check if the Point p locates inside the Dimension.
|
static boolean |
isRightMouseButton(int buttonNumber) |
static boolean |
isSafari(org.openqa.selenium.WebDriver driver) |
static boolean |
isShowOnPage(org.openqa.selenium.WebElement element) |
static boolean |
isShowOnPage(org.openqa.selenium.WebElement element,
org.openqa.selenium.Point offset)
To check if a certain point of web-element is shown on the page.
If the point is not given or it is out of boundary of web-element, method will check if the web-element is fully shown on the page. |
static void |
keyDown(org.openqa.selenium.Keys keycode)
Press down a Key by Selenium's Actions API.
|
static void |
keyPress(int keycode)
Press down a Key by Java Robot.
|
static void |
keyRelease(int keycode)
Release a Key by Java Robot.
|
static void |
keyUp(org.openqa.selenium.Keys keycode)
Release a Key by Selenium's Actions API.
|
static java.util.List<GenericProcessMonitor.ProcessInfo> |
killChromeDriver(java.lang.String host)
Kill the process 'chromedriver.exe'.
|
static java.util.List<GenericProcessMonitor.ProcessInfo> |
killIEDriverServer(java.lang.String host)
Kill the process 'IEDriverServer.exe'.
|
static void |
leftDrag(org.openqa.selenium.WebElement we,
java.awt.Point start,
java.awt.Point end)
Perform a left-drag from start point to end point relative to webelement (LeftUp corner).
|
static void |
main(java.lang.String[] args)
Before running this method, please read java doc of
test_ajax_call(String) |
static void |
maximizeBrowserWindow()
Maximize current browser window
|
static void |
minimizeBrowserWindow()
This implementation does NOT really minimize the window, it is a workaround.
Note: set the size to (0,0) can NOT minimize the window. |
static void |
mouseHover(org.openqa.selenium.WebElement we,
java.awt.Point point,
int millisStay) |
static void |
mouseWheel(int wheelAmt)
Scroll the mouse wheel by Java Robot.
|
static void |
resizeBrowserWindow(int width,
int height)
Resize current browser window
|
static void |
rightclick(org.openqa.selenium.WebElement clickable,
org.openqa.selenium.Keys specialKey,
java.lang.String... optional)
Click(Mouse Right Button) the WebElement at center with a special key pressed.
|
static void |
rightclick(org.openqa.selenium.WebElement clickable,
java.awt.Point offset,
java.lang.String... optional)
Click(Mouse Right Button) the WebElement at a certain coordination.
|
static void |
rightclick(org.openqa.selenium.WebElement clickable,
java.lang.String... optional)
Click(Mouse Right Button) - Click on WebElement or WebDriver object at the center
|
static void |
rightDrag(org.openqa.selenium.WebElement we,
java.awt.Point start,
java.awt.Point end)
Perform a right-drag from start point to end point relative to webelement (LeftUp corner).
|
static boolean |
runSeleniumBuilderScript(java.lang.String path,
org.apache.commons.logging.Log log,
boolean allowClose)
Run a SeBuilder JSON Script explicitly using the existing WebDriver instance.
|
static boolean |
runSeleniumBuilderScript(java.lang.String path,
org.apache.commons.logging.Log log,
com.sebuilder.interpreter.webdriverfactory.WebDriverFactory driverFactory,
java.util.HashMap<java.lang.String,java.lang.String> webDriverConfig,
java.util.Map<java.lang.String,java.lang.String> initialVars,
boolean allowClose)
Run a SeBuilder JSON Script.
|
static void |
scrollBrowserWindowBy(int x,
int y,
org.openqa.selenium.WebElement element)
scroll browser window by x and/or y number of pixels.
|
static void |
scrollBrowserWindowTo(int x,
int y,
org.openqa.selenium.WebElement element)
scroll browser window to x and/or y scroll position.
|
static void |
setClipboard(java.lang.String content)
Set content to the clipboard on local machine or on machine where the RMI server is running.
|
static void |
setDelayBetweenKeystrokes(int millisDelay)
Sets a delay in milliseconds between Robot keystrokes for both local and remote servers.
|
static void |
setPositionBrowserWindow(int x,
int y)
Set position of current browser window.
|
static void |
setTimeoutCheckAlertForClick(int timeoutCheckAlertForClick) |
static void |
setWaitReaction(boolean wait)
Set if wait for reaction to "input keys/chars" for both local and remote servers.
|
static void |
setWaitReaction(boolean wait,
int tokenLength,
int dealyForToken,
int dealy)
Set if wait for reaction to "input keys/chars" for both local and remote servers.
|
static void |
shiftLeftDrag(org.openqa.selenium.WebElement we,
java.awt.Point start,
java.awt.Point end)
Perform a left-drag from start point to end point relative to webelement (LeftUp corner)
with the "SHIFT" key pressed during the drag.
|
static boolean |
showOnPage(org.openqa.selenium.WebElement element)
Try to show the webelement on the browser's page.
|
static boolean |
showOnPage(org.openqa.selenium.WebElement element,
java.lang.String... optional)
Try to show the webelement on the browser's page.
First, try to see if the web-element is already shown on page, if not shown on the page then it will try to move the web-element to show it on page. Finally, if the passed in parameter verify is true, it will return true only if the element is shown on the page; if the passed in parameter verify is false, it will always return true. |
static void |
startBrowser(java.lang.String BrowserName,
java.lang.String Url,
java.lang.String Id,
int timeout,
boolean isRemote)
Start browser
|
static void |
startBrowser(java.lang.String BrowserName,
java.lang.String Url,
java.lang.String Id,
int timeout,
boolean isRemote,
java.util.Map<java.lang.String,java.lang.Object> extraParameters)
Start browser
|
static void |
stopBrowser(java.lang.String ID)
Close browser (close all windows associated) indicated by ID.
|
(package private) static int |
toJavaKeyCode(org.openqa.selenium.Keys key) |
static boolean |
windowSetFocus(java.lang.String titleRegExp)
Set a specific Window matching the provided title to be the foreground window.
|
static boolean |
windowSetFocus(org.openqa.selenium.WebDriver adriver)
Attempt to SetFocus on the topmost window for the provided WebDriver.
|
static boolean |
windowSetFocus(org.openqa.selenium.WebElement element)
Attempt to SetFocus on the topmost window containing the WebElement.
|
_switchFrames, addJavaScriptEventListener, addWebDriver, checkCSSClassName, checkNotNull, clearHighlight, containFrameRS, containTagRS, executeAsyncScript, executeJavaScriptOnWebElement, executeScript, executeScript, findElement, findElements, generateFullGenericXPath, generateGenericXPath, generateSAFSFrameRecognition, generateUniqueName, getAllWindowTitles, getBoolean, getCssSelector, getDescription, getFirstQualifierPair, getFrameWebElement, getIDForWebDriver, getJS, getJsExecutionDelay, getJsTimeout, getLastBrowserWindow, getLastFrame, getLastVisitedURL, getMatchedObject, getMatchedObjects, getNthWebElement, getObject, getObject, getObjectByMultiAttributes, getObjectByQualifier, getObjectByText, getObjectByTitle, getObjectByXpathAndQualifiers, getObjectForDomain, getObjects, getObjectsByMultiAttributes, getObjectsByQualifier, getObjectsByText, getObjectsByTitle, getObjectsByXpathAndQualifiers, getObjectsForDomain, getParentWebElement, getSubItem, getTagQualifierValue, getText, getThrowableMessages, getValue, getWebDriver, getWebDriver, getWebDriverWithTitle, getWebElement, getWebElementProperty, getXpathCondition, highlight, highlight, highlightThenClear, isDisplayed, isDojoDomain, isFrameRS, isFrameWebElement, isIgnoredNonUITag, isSAPDomain, isStale, isValidBrowserID, isValidFrameRS, isVisible, js_cleanError, js_executeWithTimeout, js_getErrorCode, js_getErrorObject, js_getGlobalBoolVariable, js_getGlobalVariable, js_initError, js_initialize, js_setErrorCode, js_setErrorObject, js_setGlobalBoolVariable, js_setGlobalVariable, pageHasChanged, reconnectLastWebDriver, refreshJSExecutor, removeJavaScriptEventListener, removeWebDriver, resetXPathObjectCache, retrieveFrameRS, setJsExecutionDelay, setJsTimeout, setLastFrame, shutdown, switchFrame, switchWindow, switchWindow, switchWindow, switchWindow, useBrowser
public static final int MOUSE_BUTTON_LEFT
InputEvent.BUTTON1_MASK
public static final int MOUSE_BUTTON_MIDDLE
InputEvent.BUTTON2_MASK
public static final int MOUSE_BUTTON_RIGHT
InputEvent.BUTTON3_MASK
protected static boolean debug
public static final int DEFAULT_TIMEOUT_WAIT_CLICK
public static final int DEFAULT_TIMEOUT_WAIT_ALERT
public static final int TIMEOUT_NOWAIT
public static final int TIMEOUT_WAIT_FOREVER
public static final int DEFAULT_TIMEOUT_WAIT_ROBOT_CLICK
public static int timeoutWaitClick
public static int timeoutWaitAlert
public static int timeoutCheckAlertForClick
TIMEOUT_NOWAIT
, means we check immediately
without waiting for presence of Alert.public static int timeoutWaitRobotClick
protected static InputKeysParser keysparser
public static boolean enableClickListenerFailures
Set to 'false' when you wish to avoid these types of failures.
public static final boolean DEFAUT_AUTOSCROLL
public static WDLibrary.WD_XMLHttpRequest AJAX
public static boolean isLeftMouseButton(int buttonNumber)
public static boolean isMiddleMouseButton(int buttonNumber)
public static boolean isRightMouseButton(int buttonNumber)
public static int getTimeoutCheckAlertForClick()
public static void setTimeoutCheckAlertForClick(int timeoutCheckAlertForClick)
public static void click(org.openqa.selenium.WebElement clickable, java.lang.String... optional) throws SeleniumPlusException
clickable
- WebElement, as WebElement objoptional
- String[], the optional parameters
SeleniumPlusException
public static void click(org.openqa.selenium.WebElement clickable, org.openqa.selenium.Keys specialKey, java.lang.String... optional) throws SeleniumPlusException
clickable
- WebElement, the WebElement to click onspecialKey
- Keys, the special key to press during the clickoptional
- String[], the optional parameters
SeleniumPlusException
public static void click(org.openqa.selenium.WebElement clickable, java.awt.Point offset, java.lang.String... optional) throws SeleniumPlusException
clickable
- WebElement, the WebElement to click onoffset
- Point, the coordination relative to this WebElement to click atoptional
- String[], the optional parameters
SeleniumPlusException
public static void rightclick(org.openqa.selenium.WebElement clickable, java.lang.String... optional) throws SeleniumPlusException
clickable
- WebElement, as WebElement objoptional
- String[], the optional parameters
SeleniumPlusException
public static void rightclick(org.openqa.selenium.WebElement clickable, org.openqa.selenium.Keys specialKey, java.lang.String... optional) throws SeleniumPlusException
clickable
- WebElement, the WebElement to click onspecialKey
- Keys, the special key to presse during the clickoptional
- String[], the optional parameters
SeleniumPlusException
public static void rightclick(org.openqa.selenium.WebElement clickable, java.awt.Point offset, java.lang.String... optional) throws SeleniumPlusException
clickable
- WebElement, the WebElement to click onoffset
- Point, the coordination relative to this WebElement to click atoptional
- String[], the optional parameters
SeleniumPlusException
public static boolean inside(org.openqa.selenium.WebElement element, java.awt.Point p)
element
- WebElement, The element to get boundary to check with.p
- Point, The point to check.public static void click(org.openqa.selenium.WebElement clickable, java.awt.Point offset, org.openqa.selenium.Keys specialKey, int mouseButtonNumber, java.lang.String... optional) throws SeleniumPlusException
clickable
- WebElement, the WebElement to click onoffset
- Point, the coordination relative to this WebElement to click at.specialKey
- Keys, the special key to press during the clickmouseButtonNumber
- int, the mouse-button-number representing right, middle, or left button.
it can be MOUSE_BUTTON_LEFT
or MOUSE_BUTTON_RIGHT
.MOUSE_BUTTON_MIDDLE
NOT supported yet.optional
- String[], the optional parameters
SeleniumPlusException
public static void doubleClick(org.openqa.selenium.WebElement clickable, java.awt.Point offset, org.openqa.selenium.Keys specialKey, int mouseButtonNumber, java.lang.String... optional) throws SeleniumPlusException
clickable
- WebElement, the WebElement to click onoffset
- Point, the coordination relative to this WebElement to click at.specialKey
- Keys, the special key to press during the clickmouseButtonNumber
- int, the mouse-button-number representing right, middle, or left button.
it can be MOUSE_BUTTON_LEFT
MOUSE_BUTTON_MIDDLE
and MOUSE_BUTTON_RIGHT
NOT supported yet.optional
- String[], the optional parameters
SeleniumPlusException
public static void doubleClick(org.openqa.selenium.WebElement clickable, java.lang.String... optional) throws SeleniumPlusException
clickable
- WebElement, the WebElement to click onoptional
- String[], the optional parameters
SeleniumPlusException
public static void doubleClick(org.openqa.selenium.WebElement clickable, org.openqa.selenium.Keys specialKey, java.lang.String... optional) throws SeleniumPlusException
clickable
- WebElement, the WebElement to click onspecialKey
- Keys, the special key to press during the clickoptional
- String[], the optional parameters
SeleniumPlusException
public static void doubleClick(org.openqa.selenium.WebElement clickable, java.awt.Point offset, java.lang.String... optional) throws SeleniumPlusException
clickable
- WebElement, the WebElement to click onoffset
- Point, the coordination relative to this WebElement to click atoptional
- String[], the optional parameters
SeleniumPlusException
public static java.awt.Point getLocation(org.openqa.selenium.WebElement webelement) throws SeleniumPlusException
getLocation(WebElement, boolean)
with 2th parameter
given as false.webelement
- WebElement, the element to get locationSeleniumPlusException
#getLocation(WebElement, boolean)}
public static java.awt.Point getLocation(org.openqa.selenium.WebElement webelement, boolean useOnPageFirstly) throws SeleniumPlusException
webelement
- WebElement, the element to get locationuseOnPageFirstly
- boolean, There are 2 ways to get element's location relative to the page:
one is Coordinates.onPage()
, the other is WebElement.getLocation()
.
it seems that the 2th method (WebElement.getLocation()
) is more accurate.
But historically, we called Coordinates.onPage()
in first place.Coordinates.onPage()
will be used firstly as before.WebElement.getLocation()
will be used directlySeleniumPlusException
public static java.awt.Point getScreenLocation(org.openqa.selenium.WebElement webelement) throws SeleniumPlusException
webelement
- WebElement, a selenium webelement objectSeleniumPlusException
public static org.openqa.selenium.Keys convertToKeys(RobotKeyEvent event)
event
- RobotKeyEventpublic static org.openqa.selenium.Keys convertToKeys(int keycode)
keycode
- int, a java keycodestatic java.lang.CharSequence convertToCharacter(RobotKeyEvent event)
event
- public static void inputKeysSAFS2Selenium(org.openqa.selenium.WebElement we, java.lang.String keystrokes) throws SeleniumPlusException
Bypasses attempts to use AWT Robot for keystrokes. Attempts to convert SAFS keystrokes to Selenium low-level Actions keystrokes.
we
- WebElement to send SAFS keystrokes (or plain text).keystrokes
- SAFS keystrokes or plain text to type.SeleniumPlusException
- if we are unable to process the keystrokes successfully.public static void keyPress(int keycode) throws SeleniumPlusException
keyRelease(int)
to release the key.keycode
- int, keycode to press (e.g. KeyEvent.VK_A
)SeleniumPlusException
- if failkeyRelease(int)
public static void keyRelease(int keycode) throws SeleniumPlusException
keyPress(int)
.keycode
- int, keycode to release (e.g. KeyEvent.VK_A
)SeleniumPlusException
- if failkeyPress(int)
public static void mouseWheel(int wheelAmt) throws SeleniumPlusException
wheelAmt
- int, the wheel amount to scroll.SeleniumPlusException
- if failpublic static void keyDown(org.openqa.selenium.Keys keycode) throws SeleniumPlusException
keyUp(Keys)
to release the key.keycode
- Keys, keycode to press (e.g. Keys.CONTROL
)SeleniumPlusException
- if failkeyUp(Keys)
public static void keyUp(org.openqa.selenium.Keys keycode) throws SeleniumPlusException
keyDown(Keys)
.keycode
- Keys, keycode to release (e.g. Keys.CONTROL
)SeleniumPlusException
- if failkeyDown(Keys)
public static void setDelayBetweenKeystrokes(int millisDelay) throws SeleniumPlusException
millisDelay
- between keystrokes.SeleniumPlusException
- if we are unable to process the keystrokes successfully.Robot.setMillisBetweenKeystrokes(int)
public static int getDelayBetweenKeystrokes() throws SeleniumPlusException
SeleniumPlusException
- if we are unable to process the keystrokes successfully.Robot.setMillisBetweenKeystrokes(int)
public static void setWaitReaction(boolean wait) throws SeleniumPlusException
wait
- boolean if wait or not.SeleniumPlusException
- if fail.Robot.setWaitReaction(boolean)
public static void setWaitReaction(boolean wait, int tokenLength, int dealyForToken, int dealy) throws SeleniumPlusException
wait
- boolean, if wait or not.tokenLength
- int, the length of a token. Only if the string is longer than this
then we wait the reaction after input-keys a certain time
indicated by the parameter dealyForToken.dealyForToken
- int, The delay in millisecond to wait the reaction after input-keys
for the string as long as a token.dealy
- int, The constant delay in millisecond to wait the reaction after input-keys.SeleniumPlusException
- if fail.Robot.setWaitReaction(boolean, int, int, int)
public static void inputKeys(org.openqa.selenium.WebElement we, java.lang.String keystrokes) throws SeleniumPlusException
Attempts to use AWT Robot for keystrokes for both local and remote servers. If the remote server does NOT have an RMI Server running to receive the request, then we will attempt to convert SAFS keystrokes to Selenium Actions keystrokes and try that way.
we
- WebElement to send SAFS keystrokes; if null, the keystrokes will be sent to the focused element.keystrokes
- in SAFS format to type.SeleniumPlusException
- if we are unable to process the keystrokes successfully.Robot.inputKeys(String)
,
#inputKeysSAFS2Selenium(WebElement)
public static void inputChars(org.openqa.selenium.WebElement we, java.lang.String keystrokes) throws SeleniumPlusException
we
- WebElement to send characters; if null, the keystrokes will be sent to the focused element.keystrokes/plain
- text to type.SeleniumPlusException
- if we are unable to process the keystrokes successfully.Robot.inputKeys(String)
public static void clearClipboard() throws SeleniumPlusException
SeleniumPlusException
public static void setClipboard(java.lang.String content) throws SeleniumPlusException
content
- String, the content to set to clipboardSeleniumPlusException
public static java.lang.Object getClipboard(java.awt.datatransfer.DataFlavor dataFlavor) throws SeleniumPlusException
dataFlavor
- DataFlavor, the data flavor for the content in clipboardSeleniumPlusException
public static java.awt.Rectangle getRectangleOnScreen(org.openqa.selenium.WebElement we) throws SeleniumPlusException
we
- WebElement, the webelement object to get screen rectangleSeleniumPlusException
static int toJavaKeyCode(org.openqa.selenium.Keys key) throws SeleniumPlusException
key
- Keys, the selenium Keys valueSeleniumPlusException
public static void captureScreen(java.lang.String image) throws SeleniumPlusException
image
- - Image full path with name.SeleniumPlusException
public static void mouseHover(org.openqa.selenium.WebElement we, java.awt.Point point, int millisStay) throws SeleniumPlusException
we
- WebElement, the component to hover mousepoint
- Point, the position relative to the component to hover the mousemillisStay
- int, in milliseconds, the period to hover the mouse; the mouse will
be moved out of screen if it expires.Constants.TIMEOUT_HOVERMOUSE_STAY_FOREVER
, then
the mouse will always stay there forever.SeleniumPlusException
- if the hover failpublic static void altLeftDrag(org.openqa.selenium.WebElement we, java.awt.Point start, java.awt.Point end) throws SeleniumPlusException
we
- WebElement, the component relative to which to dragstart
- Point, the start point relative to the webelementend
- Point, the end point relative to the webelementSeleniumPlusException
public static void ctrlAltLeftDrag(org.openqa.selenium.WebElement we, java.awt.Point start, java.awt.Point end) throws SeleniumPlusException
we
- WebElement, the component relative to which to dragstart
- Point, the start point relative to the webelementend
- Point, the end point relative to the webelementSeleniumPlusException
public static void ctrlLeftDrag(org.openqa.selenium.WebElement we, java.awt.Point start, java.awt.Point end) throws SeleniumPlusException
we
- WebElement, the component relative to which to dragstart
- Point, the start point relative to the webelementend
- Point, the end point relative to the webelementSeleniumPlusException
public static void ctrlShiftLeftDrag(org.openqa.selenium.WebElement we, java.awt.Point start, java.awt.Point end) throws SeleniumPlusException
we
- WebElement, the component relative to which to dragstart
- Point, the start point relative to the webelementend
- Point, the end point relative to the webelementSeleniumPlusException
public static void shiftLeftDrag(org.openqa.selenium.WebElement we, java.awt.Point start, java.awt.Point end) throws SeleniumPlusException
we
- WebElement, the component relative to which to dragstart
- Point, the start point relative to the webelementend
- Point, the end point relative to the webelementSeleniumPlusException
public static void rightDrag(org.openqa.selenium.WebElement we, java.awt.Point start, java.awt.Point end) throws SeleniumPlusException
we
- WebElement, the component relative to which to dragstart
- Point, the start point relative to the webelementend
- Point, the end point relative to the webelementSeleniumPlusException
public static void leftDrag(org.openqa.selenium.WebElement we, java.awt.Point start, java.awt.Point end) throws SeleniumPlusException
we
- WebElement, the component relative to which to dragstart
- Point, the start point relative to the webelementend
- Point, the end point relative to the webelementSeleniumPlusException
public static java.awt.Point getElementOffsetScreenLocation(org.openqa.selenium.WebElement element, java.lang.String offsetX, java.lang.String offsetY)
element
- WebElement, the element relative to which the coordination will be calculated.offsetX
- String, the offset on x axis, in pixel or in percentage, for example 15 or 30%.offsetX
- String, the offset on y axis, in pixel or in percentage, for example 45 or 50%.public static void captureScreen(org.openqa.selenium.WebElement we, java.lang.String imgName, java.lang.String fileformat) throws SeleniumPlusException
we
- - WebElement object.imgName
- - Image full path with namejava.lang.Exception
SeleniumPlusException
public static java.awt.image.BufferedImage captureBrowserArea(java.awt.Rectangle rectangle) throws SeleniumPlusException
rectangle
- Rectangle, within which to capture the image.SeleniumPlusException
public static void startBrowser(java.lang.String BrowserName, java.lang.String Url, java.lang.String Id, int timeout, boolean isRemote) throws SeleniumPlusException
BrowserName
- String, Browser name such as InternetExplorer, Chrome and FireFox.Url
- String, Url including HTTP protocol prefix.Id
- String, Id or Title of the Browser in case of two instances needs.timeout
- String, Implicit time out to be waited before throw exception.isRemote
- String, Start interactive testcase development mode.SeleniumPlusException
#startBrowser(String, String, String, int, boolean, Map)}
public static void startBrowser(java.lang.String BrowserName, java.lang.String Url, java.lang.String Id, int timeout, boolean isRemote, java.util.Map<java.lang.String,java.lang.Object> extraParameters) throws SeleniumPlusException
Expects System Properties 'selenium.host' and 'selenium.port' to be set.
Otherwise, defaults to 'localhost' on port '4444'.
BrowserName
- String, Browser name such as InternetExplorer, Chrome and FireFox.Url
- String, Url including HTTP protocol prefix.Id
- String, Id or Title of the Browser in case of two instances needs.timeout
- String, Implicit time out to be waited before throw exception.isRemote
- String, Start interactive testcase development mode.extraParameters
- MapSeleniumPlusException
public static void stopBrowser(java.lang.String ID) throws java.lang.IllegalArgumentException
ID
- String, the id to identify the browserjava.lang.IllegalArgumentException
- if the provided browser ID is NOT SearchObject.isValidBrowserID(String)
or not known as a running instance.SearchObject.removeWebDriver(String)
public static void resizeBrowserWindow(int width, int height) throws SeleniumPlusException
width
- int, width in pixelsheight
- int, height in pixelsSeleniumPlusException
public static java.util.List<GenericProcessMonitor.ProcessInfo> killChromeDriver(java.lang.String host) throws SAFSException
host
- String, the name of the machine on which the process 'chromedriver.exe' will be killed.SAFSException
public static java.util.List<GenericProcessMonitor.ProcessInfo> killIEDriverServer(java.lang.String host) throws SAFSException
host
- String, the name of the machine on which the process 'IEDriverServer.exe' will be killed.SAFSException
public static void scrollBrowserWindowBy(int x, int y, org.openqa.selenium.WebElement element) throws SeleniumPlusException
x
- int, horizontal scrolling in pixelsy
- int, vertical scrolling in pixelselement,
- scroll the topmost window containing this element.SeleniumPlusException
public static void scrollBrowserWindowTo(int x, int y, org.openqa.selenium.WebElement element) throws SeleniumPlusException
x
- int, horizontal position in pixelsy
- int, vertical position in pixelselement,
- scroll the topmost window containing this element.SeleniumPlusException
public static void alignToTop(org.openqa.selenium.WebElement element) throws SeleniumPlusException
element
- WebElement, the element to scroll to align with browser's topSeleniumPlusException
public static void alignToBottom(org.openqa.selenium.WebElement element) throws SeleniumPlusException
element
- WebElement, the element to scroll to align with browser's bottomSeleniumPlusException
public static boolean showOnPage(org.openqa.selenium.WebElement element)
element
- WebElement, the webelement to show.public static boolean showOnPage(org.openqa.selenium.WebElement element, java.lang.String... optional)
element
- WebElement, the webelement to show.params
- optionalpublic static boolean isShowOnPage(org.openqa.selenium.WebElement element)
element
- WebElement, to check if it is shown on the pagepublic static boolean isShowOnPage(org.openqa.selenium.WebElement element, org.openqa.selenium.Point offset)
element
- WebElement, to check if it is shown on the pageoffset
- Point, the offset from Left-Top of web-element; the point to check. can be nullpublic static boolean isLocationInBounds(org.openqa.selenium.Point p, org.openqa.selenium.Dimension bounds)
p
- Point, relative to the Dimension. Usually the top-left point of an item.
see if the Point is inside bounds of 0,0,bounds.width, bounds.height.bounds
- Dimension, the boundarypublic static boolean isPointInBounds(org.openqa.selenium.Point p, org.openqa.selenium.Dimension bounds)
p
- Point, point relative to 0,0, bounds.width, bounds.height.
Usually this is the bottom-right point test of a boundary.bounds
- Dimension, the boundarypublic static void setPositionBrowserWindow(int x, int y) throws SeleniumPlusException
x
- int, x-coordination in pixelsy
- int, y-coordination in pixelsSeleniumPlusException
public static void maximizeBrowserWindow() throws SeleniumPlusException
SeleniumPlusException
public static void minimizeBrowserWindow() throws SeleniumPlusException
SeleniumPlusException
public static org.openqa.selenium.WebDriver getBrowserWithTitle(java.lang.String title) throws SeleniumPlusException
title
- SeleniumPlusException
public static void closeBrowser() throws SeleniumPlusException
SeleniumPlusException
- if the lastUsed WebDriver is not valid or is null.stopBrowser(String)
public static org.openqa.selenium.WebDriver getBrowserWithID(java.lang.String id) throws SeleniumPlusException
id
- SeleniumPlusException
public static void highlightElement(org.openqa.selenium.WebElement element) throws SeleniumPlusException
SearchObject.highlight(WebElement)
.element
- to be highlightedSeleniumPlusException
public static java.lang.String getBrowserName(org.openqa.selenium.WebDriver driver)
driver
- -- can be null to use the last used WebDriver session.SelectBrowser.BROWSER_NAME_CHROME
,
SelectBrowser.BROWSER_NAME_FIREFOX
,
SelectBrowser.BROWSER_NAME_HTMLUNIT
,
SelectBrowser.BROWSER_NAME_IE
,
SelectBrowser.BROWSER_NAME_SAFARI
public static boolean isHtmlUnit(org.openqa.selenium.WebDriver driver)
driver
- -- can be null to use last used webdriver session.getBrowserName(WebDriver)
,
SelectBrowser.BROWSER_NAME_HTMLUNIT
public static boolean isSafari(org.openqa.selenium.WebDriver driver)
driver
- -- can be null to use last used webdriver session.getBrowserName(WebDriver)
,
SelectBrowser.BROWSER_NAME_SAFARI
public static boolean isFireFox(org.openqa.selenium.WebDriver driver)
driver
- -- can be null to use last used webdriver session.getBrowserName(WebDriver)
,
SelectBrowser.BROWSER_NAME_FIREFOX
public static boolean isInternetExplorer(org.openqa.selenium.WebDriver driver)
driver
- -- can be null to use last used webdriver session.getBrowserName(WebDriver)
,
SelectBrowser.BROWSER_NAME_IE
public static boolean isChrome(org.openqa.selenium.WebDriver driver)
driver
- -- can be null to use last used webdriver session.getBrowserName(WebDriver)
,
SelectBrowser.BROWSER_NAME_CHROME
public static com.sebuilder.interpreter.Script getSeleniumBuilderScript(java.lang.String path) throws java.io.FileNotFoundException
path
- -- full path to the JSON script.java.io.FileNotFoundException
- -- if a provided path is null or otherwise invalidpublic static com.sebuilder.interpreter.webdriverfactory.WebDriverFactory getWebDriverAsWebDriverFactory()
public static boolean runSeleniumBuilderScript(java.lang.String path, org.apache.commons.logging.Log log, com.sebuilder.interpreter.webdriverfactory.WebDriverFactory driverFactory, java.util.HashMap<java.lang.String,java.lang.String> webDriverConfig, java.util.Map<java.lang.String,java.lang.String> initialVars, boolean allowClose) throws java.io.FileNotFoundException, java.lang.RuntimeException
path
- - fullpath to JSON script file.
log
- - An appropriate logging interface--such as the ApacheLogUtilities we instantiate
when launching our Selenium engine.
driverFactory
- -- if null, we will use a default Factory that does NOT instantiate a new
WebDriver but uses the "current" or "lastUsed" WebDriver ignoring any webDriverConfig that may
or may not be provided.
Consult the Selenium Interpreter documentation for any additional info on using the Selenium Builder Interpreter if you are NOT intending to use the current or lastUsed WebDriver.
webDriverConfig
- -- can be null if driverFactory is null and we will be using an existing
WebDriver.initialVars
- -- can be null.allowClose
- -- set to false to prevent the script from closing the Driver.java.io.FileNotFoundException
java.lang.RuntimeException
public static boolean runSeleniumBuilderScript(java.lang.String path, org.apache.commons.logging.Log log, boolean allowClose) throws java.io.FileNotFoundException, java.lang.RuntimeException
path
- - fullpath to JSON script file.
log
- - An appropriate logging interface--such as the ApacheLogUtilities we instantiate
when launching our Selenium engine.
allowClose
- -- set to false to prevent the script from closing the Driver.java.io.FileNotFoundException
java.lang.RuntimeException
public static boolean windowSetFocus(org.openqa.selenium.WebElement element) throws SeleniumPlusException
element
- WebElement from which to get the proper RemoteWebDriverSeleniumPlusException
- if an error occured during the execution attempt.windowSetFocus(WebDriver)
public static boolean windowSetFocus(org.openqa.selenium.WebDriver adriver) throws SeleniumPlusException
adriver
- WebDriver from which to get the window titleSeleniumPlusException
- if an error occured during the execution attempt.windowSetFocus(String)
public static boolean windowSetFocus(java.lang.String titleRegExp) throws SeleniumPlusException
titleRegExp
- -- title or regular expression matching the target window's caption.SeleniumPlusException
NativeWrapper#SetForegroundWindow(String)}
public static boolean focus(org.openqa.selenium.WebElement element) throws SeleniumPlusException
element
- WebElement, to get focus.SeleniumPlusException
public static java.util.Map<java.lang.String,java.lang.String> getCssValues(org.openqa.selenium.WebElement element)
element
- - WebElementpublic static java.lang.String getProperty(org.openqa.selenium.WebElement element, java.lang.String property) throws SeleniumPlusException
element
- WebElement, from which to retrieve the propertyproperty
- String, the property nameSeleniumPlusException
- if the attribute or property is not found.getProperties(WebElement)
public static java.util.Map<java.lang.String,java.lang.Object> getProperties(org.openqa.selenium.WebElement element) throws SeleniumPlusException
element
- WebElement, from which to retrieve all propertiesSeleniumPlusException
public static void fireMouseEvent(MouseEvent event) throws SeleniumPlusException
event
- SeleniumPlusException
- on an execution error.java.lang.NullPointerException
- if required parameters in the MouseEvent are null.public static java.lang.String getBrowserName()
public static java.lang.String getBrowserVersion()
public static java.lang.String getPlatform()
public static java.lang.String getDriverVersion()
public static void checkKnownIssue(java.lang.String keyword) throws SeleniumPlusException
keyword
- String, the keyword to check for, such like "GetURL"SeleniumPlusException
- will be thrown out if a known issue is checked.public static boolean clickUnverified(org.openqa.selenium.WebElement component, java.awt.Point offset, java.lang.String... optional)
#click(WebElement, Point)
instead.#click(WebElement, Point)
will callcomponent
- WebElement, the component to clickoffset
- Point, the offset (relative to component) to click atoptional
- String[], the optional parameters
#click(WebElement, Point)
public static void closeAlert(boolean accept, java.lang.String... optionals) throws SeleniumPlusException
SearchObject.getWebDriver()
will still return the same object.accept
- boolean, if true then accept (click OK) the alert; otherwise dismiss (click Cancel) the alert.optionals
- String
SeleniumPlusException,
- if WebDriver cannot be got according to the parameter browserID.SeleniumPlusException
public static boolean isAlertPresent(java.lang.String... optionals) throws SeleniumPlusException
SearchObject.getWebDriver()
will still return the same object.optionals
- String...
TIMEOUT_NOWAIT
, this method will try to get Alert without waiting.SeleniumPlusException
- if the WebDriver is nullwaitAlert(String...)
public static void main(java.lang.String[] args)
test_ajax_call(String)
args
- Copyright © SAS Institute. All Rights Reserved.