public abstract class SeleniumPlus extends SAFSPlus
NOTE 1: Auto-evaluated expression. As SeleniumPlus inherits from SAFS, so it has the ability to process string as an expression. For example, "36+9", "25*6" will be calculated as "45", "150" automatically; "^" is considered as the leading char of a variable, hence "^var" will be considered as a variable "var", if variable "var" exists, then "^var" will be replaced by its value, otherwise replaced by empty string "". This ability is very useful for user, but sometimes it will cause UN-EXPECTED result during calling SeleniumPlus's API. For example, user wants to input a string "this is a combined-word" to an EditBox, the EditBox will receive "this is a 0", which is not an expected result; user wants to select all text of an EditBox, he uses "Ctrl+a" by calling SeleniumPlus.TypeKeys("^a") and he finds that doesn't work (the reason is that "^a" is parsed to "", because "^a" is considered as variable). To avoid the problem caused by arithmetic char "+ - * /", we can call API Misc.Expressions(false) to turn off the parse of an expression.For more info on command-line options, seeMisc.Expressions(false); SeleniumPlus.TypeChars("this is a combined-word"); ComboBox.CaptureItemsToFile(combobox, "ComboBoxData.txt", "UTF-8");
To avoid the problem caused by caret ^ or by arithmetic char "+ - * /", we can double-quote the parameterSeleniumPlus.TypeKeys("\"^p\"")); SeleniumPlus.TypeKeys(quote("^p")));//quote is a static method provided by SeleniumPlus SeleniumPlus.TypeChars(quote("this is a combined-word"));
NOTE 2: File path deducing. In SeleniumPlus, there are some APIs like CaptureXXXToFile, VerifyXXXToFile, they require file-path as parameter. As our doc is not very clear, user may confuse with the file-path parameter. Let's make it clear: There are 2 types of file, the test-file and bench-file. User can provide absolute or relative file-path for them. If it is absolute, there is not confusion. If it is relative, we will combine it with a base-directory to form an absolute file. The base-directory depends on the type of file (test or bench): if it is test-file, the base-directory will be the test-directory,/Actuals/ if it is bench-file, the base-directory will be the bench-directory, /Benchmarks/ After the combination, the combined-file-name will be tested, if it is not valid, the project-directory will be used as base-directory. NOTE 3: DDVariable To use DDVariable ability, PLEASE remember to turn on the Expression by Misc.Expressions(true); The DDVariable is a variable reference, it can be expressed by a leading symbol ^ and the "variable name". For example: ^user.name ^user.password DDVariable can be used along with an assignment or by itself, example as following: Misc.Expressions(true); //set value "UserA" to variable "user.name", set "Password1" to variable "user.password" Misc.SetVariableValues("^user.name=UserA","^user.password=Password1"); //input the value of variable "user.name" Component.InputCharacters(Map.AUT.UserInput, "^user.name"); //input the value of variable "user.password" Component.InputCharacters(Map.AUT.PassWord, "^user.password");
NOTE 4: a known issue about clicking on wrong item Please to TURN OFF the browser's status bar.
main(String[])
.Modifier and Type | Class and Description |
---|---|
static class |
SeleniumPlus.Assert
A set of assertions methods for tests.
|
static class |
SeleniumPlus.CheckBox
Wrapper class providing APIs to handle CheckBox keywords, like Check, UnCheck.
|
static class |
SeleniumPlus.ComboBox
Wrapper class providing APIs to handle ComboBox keywords, like Select, ShowList, SetTextValue etc.
|
static class |
SeleniumPlus.Component
Wrapper class to handle
GenericMasterFunctions Reference and
GenericObjectFunctions Reference, like VerifyProperty, IsPropertyExist etc.
|
static class |
SeleniumPlus.Counters
Wrapper class providing APIs to handle DriverCounter keywords, like StartTestSuite, StartCounter, LogCounterInfo etc.
|
static class |
SeleniumPlus.EditBox
Wrapper class providing APIs to handle EditBox keywords, like SetTextValue, SetTextCharacters etc.
|
static class |
SeleniumPlus.Files
Wrapper class providing APIs to handle File keywords, like OpenFile, ReadFileLine etc.
|
static class |
SeleniumPlus.ListView
Wrapper class providing APIs to handle ListView keywords, like ClickIndex, VerifyListContains etc.
|
static class |
SeleniumPlus.Logging
Wrapper class providing APIs to handle Logging keywords, like LogMessage, LogTestWarning etc.
|
static class |
SeleniumPlus.Menu
Wrapper class providing APIs to handle MenuBar/Menu keywords, like SelectMenuItem, VerifyMenuItemContains etc.
|
static class |
SeleniumPlus.Misc
Convenience class for miscellaneous Driver Commands.
This is a sub-class of SAFSPlus.Misc and it provides more convenient wrapper APIs related to Selenium.The class SAFSPlus.Misc is a sub-class of DriverCommand . |
static class |
SeleniumPlus.Rest
Wrapper class providing APIs to handle
TIDRestFunctions Reference and
DriverRestCommands Reference, like RestGetBinary, RestStoreResponse etc.
|
static class |
SeleniumPlus.ScrollBar
Wrapper class providing APIs to handle ScrollBar keywords, like OneDown, PageDown, PageUp etc.
|
static class |
SeleniumPlus.Strings
Wrapper class providing APIs to handle String keywords, like Compare, GetMultiDelimitedField etc.
|
static class |
SeleniumPlus.TabControl
Wrapper class providing APIs to handle TabControl keywords, like ClickTab, SelectTabIndex etc.
|
static class |
SeleniumPlus.Tree
Wrapper class providing APIs to handle Tree keywords, like ClickTextNode, ExpandTextNode etc.
|
static class |
SeleniumPlus.WDTimeOut
This class provides some static methods to set Selenium WebDriver's timeout thread-safely.
|
static class |
SeleniumPlus.Window
Wrapper class to handle Window keywords, like Maximize, Minimize, SetPosition etc.
|
SAFSPlus.DriverCommand
Modifier and Type | Field and Description |
---|---|
static EmbeddedHookDriverRunner |
Runner
The Runner object providing access to the underlying Selenium Engine.
|
static java.lang.String |
TEMP_SELENIUM_PLUS_RS_VAR |
_autorun, _autorunClassProvided, _isSPC, _junit, allowExit, ARG_AUTORUN, ARG_AUTORUN_CLASS, ARG_JUNIT, ARG_SAFSVAR, DefaultRunner, exitCode, normalizeTextForInput, prevResults, RELATIVE_TO_PARENT, RELATIVE_TO_SCREEN
Constructor and Description |
---|
SeleniumPlus()
Internal framework use only.
|
Modifier and Type | Method and Description |
---|---|
static void |
AbortTest(java.lang.String reason)
Abort running test flow.
|
static boolean |
AltLeftDrag(Component comp,
java.lang.String coordinates)
A Alt left mouse drag is performed on the object based on the stored coordinates relative to this object.
|
static boolean |
Click(Component comp,
java.lang.String... params)
Click on any visible component.
|
static boolean |
ClickUnverified(Component comp,
java.awt.Point offset)
Click on any visible component without verification.
This API will not guarantee that the click does happen, it simply clicks. |
static boolean |
CtrlAltLeftDrag(Component comp,
java.lang.String coordinates)
A Ctrl Alt left mouse drag is performed on the object based on the stored coordinates relative to this object.
|
static boolean |
CtrlClick(Component comp,
java.lang.String... params)
Control-Click on any visible component.
|
static boolean |
CtrlLeftDrag(Component comp,
java.lang.String coordinates)
A Ctrl left mouse drag is performed on the object based on the stored coordinates relative to this object.
|
static boolean |
CtrlRightClick(Component comp,
java.lang.String... params)
Control-Right-Click on any visible component.
|
static boolean |
CtrlShiftLeftDrag(Component comp,
java.lang.String coordinates)
A Ctrl Shift left mouse drag is performed on the object based on the stored coordinates relative to this object.
|
static java.lang.String |
deduceFilterAreas(Component parent,
Component[] childrenToMask)
Generate a "filter string" (Filter=x1,y1,x2,y2 x1,y1,x2,y2) according to a parent component and an array of children.
The deduced "filter string" can be used in GetGUIImage(org.safs.model.Component, String, String...) orVerifyGUIImageToFile(org.safs.model.Component, String, String...) . |
static boolean |
DoubleClick(Component comp,
java.lang.String... params)
Double-Click on any visible component.
|
static java.lang.Object |
executeAsyncScript(java.lang.String script,
java.lang.Object... scriptParams)
Following explanations come from Selenium Java Doc.
Execute an asynchronous piece of JavaScript in the context of the currently selected frame or window. |
static boolean |
ExecuteScript(Component comp,
java.lang.String script,
java.lang.String... scriptParams)
Execute a simple piece of javascript on component synchronously.
|
static java.lang.Object |
executeScript(java.lang.String script,
java.lang.Object... scriptParams)
Following explanations come from Selenium Java Doc.
Executes JavaScript synchronously in the context of the currently selected frame or window. |
static boolean |
GetGUIImage(Component comp,
java.lang.String fileName,
java.lang.String... params)
Take a screenshot of windows or component.
See Detailed Reference |
static boolean |
GetGUIImage(Component comp,
java.lang.String fileName,
java.lang.String subArea,
Component[] childrenToMask)
Take a screenshot of windows or component and filter some children inside.
|
static org.openqa.selenium.WebElement |
getObject(Component component)
Find the WebElement according to the SAFS Component.
This method will use the last webdriver as search context to find element, if user wants to find an element within an other context, please call #getObject(SearchContext, String) |
static org.openqa.selenium.WebElement |
getObject(org.openqa.selenium.SearchContext sc,
Component component)
Find the WebElement according to the SAFS Component.
|
static java.lang.String |
GetVariableValue(java.lang.String variableName)
Convenience routine to retrieve the value of a SAFS Variable stored in SAFSVARS.
|
static boolean |
Highlight(boolean OnOff)
Highlight object
|
static boolean |
HoverScreenLocation(java.lang.String coordination,
java.lang.String... optionals)
Hover the mouse over a specified screen location.
|
static boolean |
LeftDrag(Component comp,
java.lang.String coordinates)
A left mouse drag is performed on the object based on the stored coordinates relative to this object.
|
static void |
main(java.lang.String[] args)
Internal framework use only.
|
static boolean |
Pause(int seconds)
Pause test-case flow in seconds.
|
static boolean |
PrintTestCaseSummary(java.lang.String tcname)
Stop capturing test activity counts for a specific application feature or test-case if it is
still active, then print a summary report of all tests counted, passed, failed, and skipped, etc...
|
static boolean |
PrintTestSuiteSummary(java.lang.String suitename)
Stop capturing test activity counts for the overall suite of tests if it is
still active, then print a summary report of all counted, passed, failed, and skipped tests etc...
|
static boolean |
RightClick(Component comp,
java.lang.String... params)
Right-Click on any visible component.
|
static boolean |
RightDrag(Component comp,
java.lang.String coordinates)
A right mouse drag is performed on the object based on the stored coordinates relative to this object.
|
static boolean |
SetVariableValue(java.lang.String variableName,
java.lang.String variableValue)
Convenience routine to set the value of a SAFS Variable stored in SAFSVARS.
The act of logging success or failure will change prevResults. |
static boolean |
ShiftClick(Component comp,
java.lang.String... params)
Shift-Click on any visible component.
|
static boolean |
ShiftLeftDrag(Component comp,
java.lang.String coordinates)
A Shift left mouse drag is performed on the object based on the stored coordinates relative to this object.
|
static boolean |
StartTestCase(java.lang.String tcname)
Start capturing test activity counts for a specific application feature or test-case.
|
static boolean |
StartTestSuite(java.lang.String suitename)
Start capturing test activity counts for the named test suite.
|
static boolean |
StartWebBrowser(java.lang.String URL,
java.lang.String BrowserID,
java.lang.String... params)
Start WebBrowser
See Detailed Reference
|
static boolean |
StopTestCase(java.lang.String tcname)
Stop capturing test activity counts for a specific application feature or test-case.
|
static boolean |
StopWebBrowser(java.lang.String BrowserID)
Stop WebBrowser by ID.
|
static boolean |
SwitchWebBrowser(java.lang.String ID)
Switch WebBrowser by ID.
|
static boolean |
TypeChars(java.lang.String textvalue)
Sends characters to the current focused Component.
See Detailed Reference |
static boolean |
TypeEncryption(java.lang.String encryptedDataFile,
java.lang.String privateKeyFile)
Sends secret-text (such as password) to the current focused Component.
See Detailed Reference |
static boolean |
TypeKeys(java.lang.String keystrokes)
Sends keystrokes to the current focused Component.
See Detailed Reference |
static boolean |
VerifyBinaryFileToFile(java.lang.String benchFile,
java.lang.String actualFile,
java.lang.String... optionals)
Verify the current contents of a binary (image) file with a benchmark file.
|
static boolean |
VerifyFileToFile(java.lang.String benchFile,
java.lang.String actualFile,
java.lang.String... optionals)
Verify the current contents of a text file with a benchmark file (same as VerifyTextFileToFile).
|
static boolean |
VerifyGUIImageToFile(Component comp,
java.lang.String benchFile,
java.lang.String... params)
Verify the screen shot of a GUI component with a benchmark image file.
|
static boolean |
VerifyTextFileToFile(java.lang.String benchFile,
java.lang.String actualFile,
java.lang.String... optionals)
Verify the current contents of a text file with a benchmark file (same as VerifyFileToFile).
|
static boolean |
VerifyValueContains(java.lang.String wholeString,
java.lang.String substring,
java.lang.String... optionals)
Verify that a string value contains a substring.
|
static boolean |
VerifyValueContainsIgnoreCase(java.lang.String wholeString,
java.lang.String substring,
java.lang.String... optionals)
Verify that a string value contains a substring, ignoring case.
|
static boolean |
VerifyValueDoesNotContain(java.lang.String wholeString,
java.lang.String substring,
java.lang.String... optionals)
Verify that a string value does NOT contain a substring.
|
static boolean |
VerifyValues(java.lang.String value1,
java.lang.String value2,
java.lang.String... optionals)
Verify that two string values are identical.
|
static boolean |
VerifyValuesIgnoreCase(java.lang.String value1,
java.lang.String value2,
java.lang.String... optionals)
Verify that two string values are identical, ignoring case.
|
static boolean |
VerifyValuesNotEqual(java.lang.String value1,
java.lang.String value2,
java.lang.String... optionals)
Verify that two string values are NOT identical.
|
static boolean |
WaitForGUI(Component comp,
long time)
Wait for object in seconds
|
static org.openqa.selenium.WebDriver |
WebDriver()
Retrieve a reference to the Selenium WebDriver object used by the currently active (last) session.
|
_processArgs, _resolveDDVariables, action, actionGUILess, autorun, combineParams, command, debug, error, getAllowExit, getExitCode, getRunner, normalizeTextForInput, quote, quotePath, replaceSeparator, runTest, setAllowExit, setExitCode, setNormalizeTextForInput, setRunner, testStatusCode
public static final EmbeddedHookDriverRunner Runner
public static final java.lang.String TEMP_SELENIUM_PLUS_RS_VAR
public SeleniumPlus()
public static boolean StartWebBrowser(java.lang.String URL, java.lang.String BrowserID, java.lang.String... params)
URL
- String,BrowserID
- String, Unique application/browser ID.params
- optional
DCDriverCommand.DEFAULT_BROWSER
), it can be one of:
params[1] timeout int, in seconds. Implicit timeout for search elements
params[2] isRemote boolean, (no longer used -- everything is now "remote")
Following parameters indicate the extra parameters, they MUST be given by PAIR(key, value)
The key can be one of:
params[3] extra parameter key1
params[4] extra parameter value for key1
params[5] extra parameter key2
params[6] extra parameter value for key2
params[7] extra parameter key3
params[8] extra parameter value for key3
...
SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
,
StopWebBrowser(String)
,
SwitchWebBrowser(String)
StartWebBrowser("http://www.google.com", "GoogleMain"); StartWebBrowser("http://www.google.com", "GoogleMain", SelectBrowser.BROWSER_NAME_CHROME); StartWebBrowser("http://www.google.com", "GoogleMain", SelectBrowser.BROWSER_NAME_IE, "10"); The following gives some examples to start web browser with "custom profile" and "preferences". For the detail explanation of starting browser with "custom profile" and/or "preferences", please visit the section "Start Browser" at Selenium Welcome Document. //Start firefox browser with custom profile "myprofile" ( Create custom profile) StartWebBrowser("http://www.google.com", "GoogleMain", new String[]{ SelectBrowser.BROWSER_NAME_FIREFOX, "10", "true", SelectBrowser.KEY_FIREFOX_PROFILE, "myprofile" }); //Start firefox browser with some preference to set. String absolutePreferenceFile = "c:\\firefoxPref.json.dat";//A json file containing chrome preferences, like { "intl.accept_languages":"zh-cn", "accessibility.accesskeycausesactivation":false, "browser.download.folderList":2 } StartWebBrowser("http://www.google.com", "GoogleMain", new String[]{ SelectBrowser.BROWSER_NAME_FIREFOX, "10", "true", quote(SelectBrowser.KEY_FIREFOX_PROFILE_PREFERENCE), quote(absolutePreferenceFile) }); //Start chrome browser with default data pool (chrome://version/, see "Profile Path") , and using the last-used user. String datapool = "C:\\Users\\some-user\\AppData\\Local\\Google\\Chrome\\User Data"; StartWebBrowser("http://www.google.com", "GoogleMain", new String[]{ SelectBrowser.BROWSER_NAME_CHROME, "10", "true", quote(SelectBrowser.KEY_CHROME_USER_DATA_DIR), datapool }); //Start chrome browser with default data pool (chrome://version/, see "Profile Path") , and using the default user. String datapool = "C:\\Users\\some-user\\AppData\\Local\\Google\\Chrome\\User Data"; StartWebBrowser("http://www.google.com", "GoogleMain", new String[]{ SelectBrowser.BROWSER_NAME_CHROME, "10", "true", quote(SelectBrowser.KEY_CHROME_USER_DATA_DIR), datapool, quote(SelectBrowser.KEY_CHROME_PROFILE_DIR), "Default" }); //Start chrome browser with custom data, and using the last-used user. StartWebBrowser("http://www.google.com", "GoogleMain", new String[]{ SelectBrowser.BROWSER_NAME_CHROME, "10", "true", quote(SelectBrowser.KEY_CHROME_USER_DATA_DIR), "c:\\chrome_custom_data"//Create custom data pool }); //Start chrome browser with custom data, and using the 1th user. StartWebBrowser("http://www.google.com", "GoogleMain", new String[]{ SelectBrowser.BROWSER_NAME_CHROME, "10", "true", quote(SelectBrowser.KEY_CHROME_USER_DATA_DIR), "c:\\chrome_custom_data",//Create custom data pool quote(SelectBrowser.KEY_CHROME_PROFILE_DIR), "Profile 1" }); //Start chrome browser with some options to be turned off. String optionsToExclude = "disable-component-update";//comma separated options to exclude, like "disable-component-update, ignore-certificate-errors", be careful, there are NO 2 hyphens before options. StartWebBrowser("http://www.google.com", "GoogleMain", new String[]{ SelectBrowser.BROWSER_NAME_CHROME, "10", "true", quote(SelectBrowser.KEY_CHROME_EXCLUDE_OPTIONS), quote(optionsToExclude) }); //Start chrome browser with some chrome-command-line-options/preferences to set. String absolutePreferenceFile = "c:\\chromePref.json.dat";//A json file containing chrome command-line-options/preferences, like { "lang":"zh-cn", "start-maximized":"", "seplus.chrome.preference.json.key":{ "intl.accept_languages":"zh-CN-pseudo", "intl.charset_default" :"utf-8"} } StartWebBrowser("http://www.google.com", "GoogleMain", new String[]{ SelectBrowser.BROWSER_NAME_CHROME, "10", "true", quote(SelectBrowser.KEY_CHROME_PREFERENCE), quote(absolutePreferenceFile) });
public static boolean StopWebBrowser(java.lang.String BrowserID)
#StartWebBrowser(String, BrowserID, String...)
#StartWebBrowser(String, BrowserID, String...)
BrowserID
- String, the BrowserID served as key to get the WebDriver from cache.Sets prevResults TestRecordHelper to the results received or null if an error occurred.
SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
,
StartWebBrowser(String, String, String...)
String browserID = "GoogleMain";
StartWebBrowser("http://www.google.com", browserID);
//do some testing, then
StopWebBrowser(browserID);
public static boolean SwitchWebBrowser(java.lang.String ID)
#StartWebBrowser(String, int, String...)
#StartWebBrowser(String, int, String...)
ID
- String, the ID served as key to get the WebDriver from cache.SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
,
StartWebBrowser(String, String, String...)
SwitchWebBrowser("GoogleNewWindow");
public static boolean TypeKeys(java.lang.String keystrokes)
This supports special key characters like:
{Enter} = ENTER Key {Tab} = TAB Key ^ = CONTROL Key with another key ( "^s" = CONTROL + s ) % = ALT Key with another key ( "%F" = ALT + F ) + = SHIFT Key with another key ( "+{Enter}" = SHIFT + ENTER )We are generally providing this support through our generic InputKeys Support.
keystrokes
- String, to send via input to the current focused Component.Robot.inputKeys(String)
,
SAFSPlus.quote(String)
SeleniumPlus.TypeKeys("% n");//"Alt+Space+n" Minimize the current window
SeleniumPlus.TypeKeys(quote("^p"));//"Ctrl+p" Open a printer window for current window
public static boolean TypeChars(java.lang.String textvalue)
textvalue
- String, to send via input to the current focused Component.Robot.inputChars(String)
,
SAFSPlus.quote(String)
SeleniumPlus.TypeChars("Test Value");
SeleniumPlus.TypeChars(quote("UTF-8"));
SeleniumPlus.TypeChars(quote("^NotVariable"));
public static boolean TypeEncryption(java.lang.String encryptedDataFile, java.lang.String privateKeyFile)
encryptedDataFile
- String, the file containing 'encrypted data' to send to the current focused Component.privateKeyFile
- String, the file containing 'private key' to decrypt the 'encrypted data'Robot.inputChars(String)
,
RSA
//D:\secretPath\private.key contains "private key", which is generated byRSA
//C:\safs\passwords\encrypted.pass contains the encrypted-data, which is encrypted byRSA
with publickeySeleniumPlus.TypeEncryption("C:\safs\passwords\encrypted.pass", "D:\secretPath\private.key" );
public static boolean HoverScreenLocation(java.lang.String coordination, java.lang.String... optionals)
coordination
- String, The screen location, such as "200;400", or a mapKey defined under "ApplicationConstants" in map fileoptionals
- SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
boolean success = SeleniumPlus.HoverScreenLocation("500, 300", "20");
boolean success = SeleniumPlus.HoverScreenLocation("locKey", "20");//locKey="500, 300" defined in map file under "ApplicationConstants"
public static boolean VerifyBinaryFileToFile(java.lang.String benchFile, java.lang.String actualFile, java.lang.String... optionals)
benchFile
- String, File used as the comparison benchmark.actualFile
- String, File used as the comparison file under test.optionals
- SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
boolean success = SeleniumPlus.VerifyBinaryFileToFile("signIn.png", "signIn.png");
boolean success = SeleniumPlus.VerifyBinaryFileToFile("c:\bench\signIn.png", "d:\test\signIn.png");
boolean success = SeleniumPlus.VerifyBinaryFileToFile("c:\bench\signIn.png", "d:\test\signIn.png", FilterMode.TOLERANCE.name, "90");
public static boolean VerifyFileToFile(java.lang.String benchFile, java.lang.String actualFile, java.lang.String... optionals)
benchFile
- String, File used as the comparison benchmark.actualFile
- String, File used as the comparison file under test.optionals
- -- NOT used yetSAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
boolean success = SeleniumPlus.VerifyFileToFile("benchFile.txt", "actualFile.txt");
boolean success = SeleniumPlus.VerifyFileToFile("c:\bench\benchFile.txt", "d:\test\actualFile.txt");
public static boolean VerifyTextFileToFile(java.lang.String benchFile, java.lang.String actualFile, java.lang.String... optionals)
benchFile
- String, File used as the comparison benchmark.actualFile
- String, File used as the comparison file under test.optionals
- -- NOT used yetSAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
boolean success = SeleniumPlus.VerifyTextFileToFile("benchFile.txt", "actualFile.txt");
boolean success = SeleniumPlus.VerifyTextFileToFile("c:\bench\benchFile.txt", "d:\test\actualFile.txt");
public static boolean VerifyValueContains(java.lang.String wholeString, java.lang.String substring, java.lang.String... optionals)
wholeString
- String, the string value to verify.substring
- String, the substringoptionals
- SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
String labelVar = "labelVariable";
Component.AssignPropertyVariable(Map.AUT.Lable,"textContent", labelVar);
String label = SeleniumPlus.GetVariableValue(labelVar);
boolean success = SeleniumPlus.VerifyValueContains(label, "labelContent");
//or
boolean success = SeleniumPlus.VerifyValueContains("^"+labelVar, "labelContent");
public static boolean VerifyValueContainsIgnoreCase(java.lang.String wholeString, java.lang.String substring, java.lang.String... optionals)
wholeString
- String, the string value to verify.substring
- String, the substringoptionals
- SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
String labelVar = "labelVariable";
Component.AssignPropertyVariable(Map.AUT.Lable,"textContent", labelVar);
boolean success = SeleniumPlus.VerifyValueContainsIgnoreCase("^"+labelVar, "subcontent");
public static boolean VerifyValueDoesNotContain(java.lang.String wholeString, java.lang.String substring, java.lang.String... optionals)
wholeString
- String, the string value to verify.substring
- String, the substringoptionals
- SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
String labelVar = "labelVariable";
Component.AssignPropertyVariable(Map.AUT.Lable,"textContent", labelVar);
boolean success = SeleniumPlus.VerifyValueDoesNotContain("^"+labelVar, "substr");
public static boolean VerifyValues(java.lang.String value1, java.lang.String value2, java.lang.String... optionals)
value1
- String, the first value to compare.value2
- String, the second value to compare.optionals
- SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
String labelVar = "labelVariable";
Component.AssignPropertyVariable(Map.AUT.Lable,"textContent", labelVar);
String label = SeleniumPlus.GetVariableValue(labelVar);
boolean success = SeleniumPlus.VerifyValues(label, "labelContent");
//or
boolean success = SeleniumPlus.VerifyValues("^"+labelVar, "labelContent");
public static boolean VerifyValuesIgnoreCase(java.lang.String value1, java.lang.String value2, java.lang.String... optionals)
value1
- String, the first value to compare.value2
- String, the second value to compare.optionals
- SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
String labelVar = "labelVariable";
Component.AssignPropertyVariable(Map.AUT.Lable,"textContent", labelVar);
boolean success = SeleniumPlus.VerifyValuesIgnoreCase("^"+labelVar, "labelcontent");
public static boolean VerifyValuesNotEqual(java.lang.String value1, java.lang.String value2, java.lang.String... optionals)
value1
- String, the first value to compare.value2
- String, the second value to compare.optionals
- SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
String labelVar = "labelVariable";
Component.AssignPropertyVariable(Map.AUT.Lable,"textContent", labelVar);
boolean success = SeleniumPlus.VerifyValuesNotEqual("^"+labelVar, "labelContent");
public static boolean Click(Component comp, java.lang.String... params)
comp
- -- Component (from App Map) to Clickparams
- optional
Sets prevResults TestRecordHelper to the results received or null if an error occurred.
SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
1) boolean success = Click(Map.Google.Apps);//Click at the center
2) boolean success = Click(Map.Google.Apps,"20,20");//Click at the coordinate (20,20)
3) boolean success = Click(Map.Google.Apps,"20%,30%"); // Click at the coordinate: its X value equals 20% width of component, its Y value equals 30% height of component.
4) boolean success = Click(Map.Google.Apps,"AppMapSubkey");//Click at the coordinate defined by entry "AppMapSubkey" in App Map.
5) boolean success = Click(Map.Google.Apps,"20,20", "false");//Click at the coordinate (20,20), and web-element will not be scrolled into view automatically
// one of the above and then,
int rc = prevResults.getStatusCode(); // if useful
String info = prevResults.getStatusInfo(); // if useful
Pay attention: If you use percentage format in SE+, you'd better use 'Misc.Expressions(false);' first.
"AppMapSubkey" is expected to be an AppMap entry in an "Apps" section in the App Map.
See Detailed Reference
public static boolean CtrlClick(Component comp, java.lang.String... params)
comp
- -- Component (from App Map) to Clickparams
- optional
Sets prevResults TestRecordHelper to the results received or null if an error occurred.
SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
1) boolean success = CtrlClick(Map.Google.Apps);//Control-Click at the center
2) boolean success = CtrlClick(Map.Google.Apps,"20,20");//Control-Click at the coordinate (20,20)
3) boolean success = CtrlClick(Map.Google.Apps,"20%,30%"); // Control-Click at the coordinate: its X value equals 20% width of component, its Y value equals 30% height of component.
4) boolean success = CtrlClick(Map.Google.Apps,"AppMapSubkey");//Control-Click at the coordinate defined by entry "AppMapSubkey" in App Map.
5) boolean success = CtrlClick(Map.Google.Apps,"20,20", "false");//Control-Click at the coordinate (20,20) and web-element will not be scrolled into view automatically
// one of the above and then,
int rc = prevResults.getStatusCode(); // if useful
String info = prevResults.getStatusInfo(); // if useful
Pay attention: If you use percentage format in SE+, you'd better use 'Misc.Expressions(false);' first.
public static boolean CtrlRightClick(Component comp, java.lang.String... params)
comp
- -- Component (from App Map) to Clickparams
- optional
Sets prevResults TestRecordHelper to the results received or null if an error occurred.
SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
1) boolean success = CtrlRightClick(Map.Google.Apps);//Control-Right-Click at the center
2) boolean success = CtrlRightClick(Map.Google.Apps,"20,20");//Control-Right-Click at the coordinate (20,20)
3) boolean success = CtrlRightClick(Map.Google.Apps,"20%,30%"); // Control-Right-Click at the coordinate: its X value equals 20% width of component, its Y value equals 30% height of component.
4) boolean success = CtrlRightClick(Map.Google.Apps,"AppMapSubkey");//Control-Right-Click at the coordinate defined by entry "AppMapSubkey" in App Map.
5) boolean success = CtrlRightClick(Map.Google.Apps,"20,20", "false");//Control-Right-Click at the coordinate (20,20) and web-element will not be scrolled into view automatically
// one of the above and then,
int rc = prevResults.getStatusCode(); // if useful
String info = prevResults.getStatusInfo(); // if useful
Pay attention: If you use percentage format in SE+, you'd better use 'Misc.Expressions(false);' first.
public static boolean DoubleClick(Component comp, java.lang.String... params)
comp
- -- Component (from App Map) to Clickparams
- optional
Sets prevResults TestRecordHelper to the results received or null if an error occurred.
SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
1) boolean success = DoubleClick(Map.Google.Apps);//Double-Click at the center
2) boolean success = DoubleClick(Map.Google.Apps,"20,20");//Double-Click at the coordinate (20,20)
3) boolean success = DoubleClick(Map.Google.Apps,"20%,30%"); // Double-Click at the coordinate: its X value equals 20% width of component, its Y value equals 30% height of component.
4) boolean success = DoubleClick(Map.Google.Apps,"AppMapSubkey");//Double-Click at the coordinate defined by entry "AppMapSubkey" in App Map.
5) boolean success = DoubleClick(Map.Google.Apps,"20,20", "false");//Double-Click at the coordinate (20,20) and web-element will not be scrolled into view automatically
// one of the above and then,
int rc = prevResults.getStatusCode(); // if useful
String info = prevResults.getStatusInfo(); // if useful
Pay attention: If you use percentage format in SE+, you'd better use 'Misc.Expressions(false);' first.
public static boolean RightClick(Component comp, java.lang.String... params)
comp
- -- Component (from App Map) to Clickparams
- optional
Sets prevResults TestRecordHelper to the results received or null if an error occurred.
SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
1) boolean success = RightClick(Map.Google.Apps);//Right-Click at the center
2) boolean success = RightClick(Map.Google.Apps,"20,20");//Right-Click at the coordinate (20,20)
3) boolean success = RightClick(Map.Google.Apps,"20%,30%"); // Right-Click at the coordinate: its X value equals 20% width of component, its Y value equals 30% height of component.
4) boolean success = RightClick(Map.Google.Apps,"AppMapSubkey");//Right-Click at the coordinate defined by entry "AppMapSubkey" in App Map.
5) boolean success = RightClick(Map.Google.Apps,"20,20", "false");//Right-Click at the coordinate (20,20) and web-element will not be scrolled into view automatically
// one of the above and then,
int rc = prevResults.getStatusCode(); // if useful
String info = prevResults.getStatusInfo(); // if useful
Pay attention: If you use percentage format in SE+, you'd better use 'Misc.Expressions(false);' first.
public static boolean LeftDrag(Component comp, java.lang.String coordinates)
comp
- Component, the component (from App Map) relative to which to calculate coordinates to dragcoordinates
- String, the relative coordinates. Example: "Coords=3,10,12,20", or "coordsKey" defined in App MapSets prevResults TestRecordHelper to the results received or null if an error occurred.
SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
boolean success = LeftDrag(Map.Google.Apps,"3,10,12,20");//Left-Drag from (3,10) to (12,20), relative to the Left Up corner of component Map.Google.Apps
boolean success = LeftDrag(Map.Google.Apps,"Coords=3,10,12,20");//Left-Drag from (3,10) to (12,20), relative to the Left Up corner of component Map.Google.Apps
boolean success = LeftDrag(Map.Google.Apps,"coordsKey");//"coordsKey" is defined in map file under section [Apps]
//one of the above and then,
int rc = prevResults.getStatusCode(); // if useful
String info = prevResults.getStatusInfo(); // if useful
public static boolean ShiftLeftDrag(Component comp, java.lang.String coordinates)
comp
- Component, the component (from App Map) relative to which to calculate coordinates to dragcoordinates
- String, the relative coordinates. Example: "Coords=3,10,12,20", or "coordsKey" defined in App MapSets prevResults TestRecordHelper to the results received or null if an error occurred.
SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
boolean success = ShiftLeftDrag(Map.Google.Apps,"3,10,12,20");//Shift-Left-Drag from (3,10) to (12,20), relative to the Left Up corner of component Map.Google.Apps
boolean success = ShiftLeftDrag(Map.Google.Apps,"Coords=3,10,12,20");//Shift-Left-Drag from (3,10) to (12,20), relative to the Left Up corner of component Map.Google.Apps
boolean success = ShiftLeftDrag(Map.Google.Apps,"coordsKey");//"coordsKey" is defined in map file under section [Apps]
//one of the above and then,
int rc = prevResults.getStatusCode(); // if useful
String info = prevResults.getStatusInfo(); // if useful
public static boolean CtrlShiftLeftDrag(Component comp, java.lang.String coordinates)
comp
- Component, the component (from App Map) relative to which to calculate coordinates to dragcoordinates
- String, the relative coordinates. Example: "Coords=3,10,12,20", or "coordsKey" defined in App MapSets prevResults TestRecordHelper to the results received or null if an error occurred.
SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
boolean success = CtrlShiftLeftDrag(Map.Google.Apps,"3,10,12,20");//Ctrl-Shift-Left-Drag from (3,10) to (12,20), relative to the Left Up corner of component Map.Google.Apps
boolean success = CtrlShiftLeftDrag(Map.Google.Apps,"Coords=3,10,12,20");//Ctrl-Shift-Left-Drag from (3,10) to (12,20), relative to the Left Up corner of component Map.Google.Apps
boolean success = CtrlShiftLeftDrag(Map.Google.Apps,"coordsKey");//"coordsKey" is defined in map file under section [Apps]
//one of the above and then,
int rc = prevResults.getStatusCode(); // if useful
String info = prevResults.getStatusInfo(); // if useful
public static boolean CtrlLeftDrag(Component comp, java.lang.String coordinates)
comp
- Component, the component (from App Map) relative to which to calculate coordinates to dragcoordinates
- String, the relative coordinates. Example: "Coords=3,10,12,20", or "coordsKey" defined in App MapSets prevResults TestRecordHelper to the results received or null if an error occurred.
SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
boolean success = CtrlLeftDrag(Map.Google.Apps,"3,10,12,20");//Ctrl-Left-Drag from (3,10) to (12,20), relative to the Left Up corner of component Map.Google.Apps
boolean success = CtrlLeftDrag(Map.Google.Apps,"Coords=3,10,12,20");//Ctrl-Left-Drag from (3,10) to (12,20), relative to the Left Up corner of component Map.Google.Apps
boolean success = CtrlLeftDrag(Map.Google.Apps,"coordsKey");//"coordsKey" is defined in map file under section [Apps]
//one of the above and then,
int rc = prevResults.getStatusCode(); // if useful
String info = prevResults.getStatusInfo(); // if useful
public static boolean AltLeftDrag(Component comp, java.lang.String coordinates)
comp
- Component, the component (from App Map) relative to which to calculate coordinates to dragcoordinates
- String, the relative coordinates. Example: "Coords=3,10,12,20", or "coordsKey" defined in App MapSets prevResults TestRecordHelper to the results received or null if an error occurred.
SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
boolean success = AltLeftDrag(Map.Google.Apps,"3,10,12,20");//Alt-Left-Drag from (3,10) to (12,20), relative to the Left Up corner of component Map.Google.Apps
boolean success = AltLeftDrag(Map.Google.Apps,"Coords=3,10,12,20");//Alt-Left-Drag from (3,10) to (12,20), relative to the Left Up corner of component Map.Google.Apps
boolean success = AltLeftDrag(Map.Google.Apps,"coordsKey");//"coordsKey" is defined in map file under section [Apps]
//one of the above and then,
int rc = prevResults.getStatusCode(); // if useful
String info = prevResults.getStatusInfo(); // if useful
public static boolean CtrlAltLeftDrag(Component comp, java.lang.String coordinates)
comp
- Component, the component (from App Map) relative to which to calculate coordinates to dragcoordinates
- String, the relative coordinates. Example: "Coords=3,10,12,20", or "coordsKey" defined in App MapSets prevResults TestRecordHelper to the results received or null if an error occurred.
SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
boolean success = CtrlAltLeftDrag(Map.Google.Apps,"3,10,12,20");//Ctrl-Alt-Left-Drag from (3,10) to (12,20), relative to the Left Up corner of component Map.Google.Apps
boolean success = CtrlAltLeftDrag(Map.Google.Apps,"Coords=3,10,12,20");//Ctrl-Alt-Left-Drag from (3,10) to (12,20), relative to the Left Up corner of component Map.Google.Apps
boolean success = CtrlAltLeftDrag(Map.Google.Apps,"coordsKey");//"coordsKey" is defined in map file under section [Apps]
//one of the above and then,
int rc = prevResults.getStatusCode(); // if useful
String info = prevResults.getStatusInfo(); // if useful
public static boolean RightDrag(Component comp, java.lang.String coordinates)
comp
- Component, the component (from App Map) relative to which to calculate coordinates to dragcoordinates
- String, the relative coordinates. Example: "Coords=3,10,12,20", or "coordsKey" defined in App MapSets prevResults TestRecordHelper to the results received or null if an error occurred.
SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
boolean success = RightDrag(Map.Google.Apps,"3,10,12,20");//Right-Drag from (3,10) to (12,20), relative to the Left Up corner of component Map.Google.Apps
boolean success = RightDrag(Map.Google.Apps,"Coords=3,10,12,20");//Right-Drag from (3,10) to (12,20), relative to the Left Up corner of component Map.Google.Apps
boolean success = RightDrag(Map.Google.Apps,"coordsKey");//"coordsKey" is defined in map file under section [Apps]
//one of the above and then,
int rc = prevResults.getStatusCode(); // if useful
String info = prevResults.getStatusInfo(); // if useful
public static boolean ShiftClick(Component comp, java.lang.String... params)
comp
- -- Component (from App Map) to Clickparams
- optional
Sets prevResults TestRecordHelper to the results received or null if an error occurred.
SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
1) boolean success = ShiftClick(Map.Google.Apps);//Shift-Click at the center
2) boolean success = ShiftClick(Map.Google.Apps,"20,20");//Shift-Click at the coordination (20,20)
3) boolean success = ShiftClick(Map.Google.Apps,"20%,30%"); // Shift-Click at the coordinate: its X value equals 20% width of component, its Y value equals 30% height of component.
4) boolean success = ShiftClick(Map.Google.Apps,"AppMapSubkey");//Shift-Click at the coordination defined by entry "AppMapSubkey" in App Map.
5) boolean success = ShiftClick(Map.Google.Apps,"20,20", "false");//Shift-Click at the coordination (20,20) and web-element will not be scrolled into view automatically
// one of the above and then,
int rc = prevResults.getStatusCode(); // if useful
String info = prevResults.getStatusInfo(); // if useful
Pay attention: If you use percentage format in SE+, you'd better use 'Misc.Expressions(false);' first.
public static boolean Highlight(boolean OnOff)
OnOff
- -- true or false for object highlightpublic static boolean Pause(int seconds)
SAFSPlus.DriverCommand.Delay(int)
.seconds
- int, the seconds to pauseSAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
,
SAFSPlus.DriverCommand.Delay(int)
Pause(20);
public static boolean GetGUIImage(Component comp, java.lang.String fileName, java.lang.String... params)
comp
- Component, the component to get its image.fileName
- String, the file name to store image. Suggest to save as .png image.params
- optional
GetGUIImage(Map.Google.SignIn,"SignIn");//will be saved at <testProject>\Actuals\SignIn.bmp
GetGUIImage(Map.Google.SignIn,"c:/temp/SignIn.gif");
//Following example will store part of the SingIn image,
GetGUIImage(Map.Google.SignIn,"SignInPartial.png", "0,0,50%,50%");
//"subarea" is defined in map file
//[SignIn]
//subarea="0,0,50%,50%"
GetGUIImage(Map.Google.SignIn,"SignInPartial.png", "subarea");
//or
//"subarea" is defined in map file
//[ApplicationConstants]
//subarea="0,0,50%,50%"
GetGUIImage(Map.Google.SignIn,"SignInPartial.png", Map.subarea);
GetGUIImage(Map.Google.SignIn,"SignInPartial.png", Map.subarea());
//Filter the SingIn image and save it
GetGUIImage(Map.Google.SignIn,"SignInFiltered.gif", "", quote("Filter=0,0,10,10 60,60,10,10"));
//"filterAreas" is defined in map file
//[SignIn]
//filterAreas="Filter=0,0,10,10 60,60,10,10"
GetGUIImage(Map.Google.SignIn,"SignInFiltered.gif", "", "filterAreas");
//"filterAreas" is defined in map file
//[ApplicationConstants]
//filterAreas="Filter=0,0,10,10 60,60,10,10"
GetGUIImage(Map.Google.SignIn,"SignInFiltered.gif", "", Map.filterAreas);
GetGUIImage(Map.Google.SignIn,"SignInFiltered.gif", "", Map.filterAreas());
public static boolean GetGUIImage(Component comp, java.lang.String fileName, java.lang.String subArea, Component[] childrenToMask)
comp
- org.safs.model.Component, the component to get its image.fileName
- String, the file name to store image. Suggest to save as .png image.subArea
- String, (x1,y1,x2,y2) indicating partial image of the component to capture, such as "0,0,50%,50%", childrenToMask
- org.safs.model.Component[], an array of child to filter,
if some child is outside of parent, then it will be ignored.
org.safs.model.Component[] filterChildren = new org.safs.model.Component[5];
filterChildren[0]=Map.SAPDemoPage.Basc_Button;
filterChildren[1]=Map.SAPDemoPage.Basc_Radio;
filterChildren[2]=Map.SAPDemoPage.Basc_Link;
filterChildren[3]=Map.SAPDemoPage.Basc_Password;
filterChildren[4]=Map.SAPDemoPage.Basc_TextArea_L;
GetGUIImage(Map.SAPDemoPage.Panel_Basc, "Panel_Basc_Filtered.png", "", filterChildren);
//compare with image "Panel_Basc.png", which is not filtered
GetGUIImage(Map.SAPDemoPage.Panel_Basc, "Panel_Basc.png");
public static java.lang.String deduceFilterAreas(Component parent, Component[] childrenToMask)
GetGUIImage(org.safs.model.Component, String, String...)
orVerifyGUIImageToFile(org.safs.model.Component, String, String...)
. SAFSPlus.quote(String)
to wrap the "filter string" and then pass it to GetGUIImage/VerifyGUIImageToFileSAFSPlus.DriverCommand.Expressions(boolean)
parent
- org.safs.model.Component, the parent componentchildrenToMask
- org.safs.model.Component[], the children inside the parent component; the child outside of
parent component will be ignored.public static boolean VerifyGUIImageToFile(Component comp, java.lang.String benchFile, java.lang.String... params)
comp
- Component, the component to get its image.benchFile
- String, the benchmark file name. Suggest to compare with .png image.params
- optional
VerifyGUIImageToFile(Map.Google.SignIn,"SignIn");//will be compared with file <testProject>\Benchmarks\SignIn.bmp
VerifyGUIImageToFile(Map.Google.SignIn,"c:/benchDir/SignIn.gif");
VerifyGUIImageToFile(Map.Google.SignIn,"c:/benchDir/SignIn.gif", "", "", quote("UUID=False"));// Simple output filename, no UUID.
VerifyGUIImageToFile(Map.Google.SignIn,"c:/benchDir/SignIn.gif", "", "95");//if 95% bits match, the verification will pass.
//Following example will verify part of the SingIn image,
GetGUIImage(Map.Google.SignIn,"SignInPartial.png", quote("0,0,50%,50%"));
//"subarea" is defined in map file
//[SignIn]
//subarea="0,0,50%,50%"
VerifyGUIImageToFile(Map.Google.SignIn,"SignInPartial.png", "subarea");
//or
//"subarea" is defined in map file
//[ApplicationConstants]
//subarea="0,0,50%,50%"
VerifyGUIImageToFile(Map.Google.SignIn,"SignInPartial.png", Map.subarea);
VerifyGUIImageToFile(Map.Google.SignIn,"SignInPartial.png", Map.subarea());
//Filter the SingIn image and the bench image at certain areas and compare them
VerifyGUIImageToFile(Map.Google.SignIn,"c:/benchDir/SignIn.gif", "", "", "", quote("Filter=0,0,10,10 60,60,10,10"));
//"filterAreas" is defined in map file
//[SignIn]
//filterAreas="Filter=0,0,10,10 60,60,10,10"
VerifyGUIImageToFile(Map.Google.SignIn,"c:/benchDir/SignIn.gif", "", "", "", "filterAreas");
//"filterAreas" is defined in map file
//[ApplicationConstants]
//filterAreas="Filter=0,0,10,10 60,60,10,10"
VerifyGUIImageToFile(Map.Google.SignIn,"c:/benchDir/SignIn.gif", "", "", "", Map.filterAreas);
VerifyGUIImageToFile(Map.Google.SignIn,"c:/benchDir/SignIn.gif", "", "", "", Map.filterAreas());
public static boolean ExecuteScript(Component comp, java.lang.String script, java.lang.String... scriptParams)
If the script will return a string value, call SeleniumPlus.prevResults.getStatusInfo() to get it.
Object result is NOT supported yet.
You can also call executeScript(String, Object...)
instead, it is more efficient.
comp
- org.safs.model.Component, (from generated Map.java).script
- String, the javascript to execute.scriptParams
- optional, Script arguments must be a number, a boolean, a String, WebElement, or a List of any combination of the above.
An exception will be thrown if the arguments do not meet these criteria.
The arguments will be made available to the JavaScript via the "arguments" variable.
executeScript(String, Object...)
,
executeAsyncScript(String, Object...)
SeleniumPlus.ExecuteScript(
Map.Google.SignIn, // The WebElement passed as 'arguments[0]' to the script.
"arguments[0].innerHTML=arguments[1];", // Script to set the WebElements innerHTML value.
"my text value"); // The value passed as 'arguments[1]' to set to innerHTML.
SeleniumPlus.ExecuteScript(
Map.Google.SignIn, // The WebElement passed as 'arguments[0]' to the script.
"return arguments[0].innerHTML;"); // A script to return the WebElemenbts innerHTML.
// scriptResult should get the innerHTML value returned.
String scriptResult = SeleniumPlus.prevResults.getStatusInfo();
public static org.openqa.selenium.WebElement getObject(Component component) throws SeleniumPlusException
#getObject(SearchContext, String)
Component,
- The component to search.SeleniumPlusException
public static org.openqa.selenium.WebElement getObject(org.openqa.selenium.SearchContext sc, Component component) throws SeleniumPlusException
sc
- could be the WebDriver or a parent WebElement context.Component,
- The component to search.SeleniumPlusException
public static boolean WaitForGUI(Component comp, long time)
comp
- -- Component (from generated Map.java)time
- - time in second
WaitForGUI(Map.Google.SignIn,10);
public static boolean StartTestCase(java.lang.String tcname)
tcname
- The name of the test-case to start using a Counter on.Sets prevResults TestRecordHelper to the results received or null if an error occurred.
SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
public static boolean StartTestSuite(java.lang.String suitename)
suitename
- The name of the suite counter to start.Sets prevResults TestRecordHelper to the results received or null if an error occurred.
SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
TestRecordData.getStatusInfo()
public static boolean StopTestCase(java.lang.String tcname)
tcname
- The name of the test-case to stop. The name must match a counter that was
previously started.Sets prevResults TestRecordHelper to the results received or null if an error occurred.
SAFSPlus.prevResults
,
StartTestCase(String)
,
PrintTestCaseSummary(String)
public static java.lang.String GetVariableValue(java.lang.String variableName)
variableName
- Does not change prevResults.
SAFSPlus.prevResults
public static boolean SetVariableValue(java.lang.String variableName, java.lang.String variableValue)
variableName
- -- Name of variable to set.variableValue
- -- value to store in variableName.SAFSPlus.prevResults
,
SAFSPlus.DriverCommand.SetVariableValues(String, String...)
,
SAFSPlus.DriverCommand.SetVariableValueEx(String, String)
public static boolean PrintTestCaseSummary(java.lang.String tcname)
tcname
- The name of the test-case to start using a Counter on. The name must match a counter
that was previously started.Sets prevResults TestRecordHelper to the results received or null if an error occurred.
SAFSPlus.prevResults
,
StartTestCase(String)
public static boolean PrintTestSuiteSummary(java.lang.String suitename)
suitename
- The name of the suite to stop (if still running) and process.
The name must match a counter that was previously started.Sets prevResults TestRecordHelper to the results received or null if an error occurred.
SAFSPlus.prevResults
public static void AbortTest(java.lang.String reason) throws java.lang.Throwable
reason
- will be prepended to the detailed abort information.java.lang.Throwable
SAFSPlus.prevResults
AbortTest("reason for abort");
Clears prevResults TestRecordHelper to null.public static boolean ClickUnverified(Component comp, java.awt.Point offset)
Click(org.safs.model.Component, String...)
instead.comp
- -- Component (from App Map) to Clickoffset
- Point, the offset relative to the component to clickClick(org.safs.model.Component, String...)
1) boolean success = ClickUnverified(Map.Google.Apps);//Click at the center
2) boolean success = ClickUnverified(Map.Google.Apps, new Point(20,20));//Click at the coordinate (20,20)
public static org.openqa.selenium.WebDriver WebDriver()
public static java.lang.Object executeAsyncScript(java.lang.String script, java.lang.Object... scriptParams) throws SeleniumPlusException
script
- String, the script to executescriptParams
- optional, Script arguments must be a number, a boolean, a String, WebElement, or a List of any combination of the above.
An exception will be thrown if the arguments do not meet these criteria.
The arguments will be made available to the JavaScript via the "arguments" variable.
SeleniumPlusException
SearchObject.executeAsyncScript(String, Object...)
//Example #1: Performing a sleep in the browser under test.
long start = System.currentTimeMillis();
String script = "window.setTimeout(arguments[arguments.length - 1], 500);";
SeleniumPlus.executeAsyncScript(script);
System.out.println("Elapsed time: " + System.currentTimeMillis() - start);
//Example #2: Synchronizing a test with an AJAX application:
Click(Map.Mail.ComposeButton);
String script = "var callback = arguments[arguments.length - 1];" +
"mailClient.getComposeWindowWidget().onload(callback);";
Object result = SeleniumPlus.executeAsyncScript(script);
Component.InputCharacters(Map.Mail.To, "bog@example.com");
//Example #3: Injecting a XMLHttpRequest and waiting for the result:
String script = "var callback = arguments[arguments.length - 1];" +
"var xhr = new XMLHttpRequest();" +
"xhr.open('GET', '/resource/data.json', true);" +
"xhr.onreadystatechange = function() {" +
" if (xhr.readyState == 4) {" +
" callback(xhr.responseText);" +
" }" +
"};" +
"xhr.send();";
Object result = SeleniumPlus.executeAsyncScript(script);
JsonObject json = new JsonParser().parse((String) response);
public static java.lang.Object executeScript(java.lang.String script, java.lang.Object... scriptParams) throws SeleniumPlusException
script
- String, the script to executescriptParams
- optional, Script arguments must be a number, a boolean, a String, WebElement, or a List of any combination of the above.
An exception will be thrown if the arguments do not meet these criteria.
The arguments will be made available to the JavaScript via the "arguments" variable.
SeleniumPlusException
SearchObject.executeAsyncScript(String, Object...)
//set "your text" to innerHTML of component Map.Google.SignIn
WebElement we = SeleniumPlus.getObject(Map.Google.SignIn);
String script = "arguments[0].innerHTML=arguments[1];";
List<Object> params = new ArrayList<Object>();
params.add(we);//arguments[0]
params.add("your text");//arguments[1]
SeleniumPlus.executeScript(script, params.toArray(new Object[0]));
//get innerHTML of component Map.Google.SignIn
script = "return arguments[0].innerHTML;";
params.clear();
params.add(we);//arguments[0]
Object result = SeleniumPlus.executeScript(script, params.toArray(new Object[0]));
public static void main(java.lang.String[] args)
Any subclass specific initialization should be done in the default no-arg constructor for the subclass. That Constructor will be instantiated and invoked automatically by this main startup method.
By default will seek an AppMap.order file. However, the user can specify an alternate AppMap order file by using the following JVM argument:
By default, the Browser Type that will be used is FireFox. The user can specify a
different default browser by using the following JVM argument SelectBrowser.SYSTEM_PROPERTY_BROWSER_NAME
:
By default, the RemoteServer that will be used is at host and port: localhost:4444 .
The user can specify a different host and/or port (grid) by using the JVM arguments
SelectBrowser.SYSTEM_PROPERTY_SELENIUM_HOST
and SelectBrowser.SYSTEM_PROPERTY_SELENIUM_PORT
:
By default, a Debug Log is usually enabled and named in the test configuration (INI) file. The user can specify or override the name of this debug log file by using the following JVM argument:
args
- --
-safsvar:name=value
-safsvar:platform=win8 -safsvar:browserType=firefox "-safsvar:spacedpath=C:\Project With Spaces\Special Directory"
-autorunclass -- followed by the class that is requesting the automatic configuration and execution, only take effect when parameter '-autorun' is present.
-junit:classname -- perform a JUnit test instead of executing runTest() in the SeleniumPlus subclass.
The normal SeleniumPlus bootstrap process and initialization is performed prior to executing the JUnit test.
AutoConfigureJSAFS
,
JSAFSBefore
,
JSAFSAfter
,
JSAFSTest
,
InjectJSAFS
Copyright © SAS Institute. All Rights Reserved.