public static class SAFSPlus.Misc extends SAFSPlus.DriverCommand
DriverCommand
and it provides more convenient wrapper APIs.DriverCommand
Constructor and Description |
---|
Misc() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
GetAppMapValue(Component component,
java.lang.String... optionals)
According to the component, get its "recognition string" defined in App Map file.
This component can be defined in one of the App Map file of a App Map chain. |
static java.lang.String |
GetAppMapValue(java.lang.String contstant)
Get the constant value defined in App Map chain
|
static java.lang.String |
GetAppMapValue(java.lang.String section,
java.lang.String item)
According to pair (section,item), get the value defined in App Map chain
|
static int |
GetMillisBetweenRecords()
Get the general pause time between records (SAFSPlus API calls), in milliseconds.
|
static boolean |
IsComponentExists(Component component,
java.lang.String... optionals)
Test if a Window or Component exists within a timeout.
|
static boolean |
isExpressionsOn()
Return if the expression evaluation is turned on.
|
static java.lang.String |
ResolveExpression(java.lang.String expression)
Resolve a string as an expression.
If isExpressionsOn() is true, the string will be resolved as "math" and "DDVariable"If isExpressionsOn() is false, the string will be resolved as "DDVariable"Note: In SE+, the expression will be handled as "math" and "DDVariable", or not handled at all, just as described in SAFSPlus.DriverCommand.Expressions(boolean) , but sometimes we want to resolve an expression as"DDVariable" but not "math", then we can turn off expression by SAFSPlus.DriverCommand.Expressions(boolean) and call this method. |
static boolean |
SwitchWindow(java.lang.String title,
java.lang.String... optionals)
Switch to the window having title indicated by parameter title.
The window can be searched from the last used browser if parameter browserID is not provided; Or the window can be searched from the browser indicated by the parameter browserID. |
AssignClipboardVariable, CallJUnit, CallRemote, CallScript, CaptureMousePositionOnScreen, ClearAllVariables, ClearAppMapCache, ClearArrayVariables, ClearClipboard, CloseApplication, CloseApplicationMap, CopyVariableValueEx, Delay, Expressions, GetRegistryKeyValue, GetRegistryKeyValue, GetSystemDate, GetSystemDateTime, GetSystemTime, GetURL, Highlight, LaunchApplication, OnGUIExistsGotoBlockID, OnGUINotExistGotoBlockID, Pause, SaveClipboardToFile, SaveURLToFile, ScrollWheel, SendMail, SetApplicationMap, SetClipboard, SetContext, SetFocus, SetImageDebug, SetImageFuzzyMatching, SetMillisBetweenRecords, SetMultipleThreadSearch, SetVariableValueEx, SetVariableValues, StartWebBrowser, StopWebBrowser, TakeScreenShot, TakeScreenShot, UseWebBrowser, VerifyClipboardToFile, VerifyURLContent, VerifyURLToFile, WaitForGUI, WaitForGUI, WaitForGUIGone, WaitForPropertyValue, WaitForPropertyValueGone, WaitForRegistryKeyExists, WaitForRegistryKeyValue
public static java.lang.String GetAppMapValue(Component component, java.lang.String... optionals) throws SeleniumPlusException
component
- org.safs.model.Component, The component to search.optionals
- SeleniumPlusException
- if the parameter is null or the command was not executed successfully.
In map file, we have defined the followings
[Login]
UserID="xpath=foo"
In our test code, we want to get the string value defined in map for item "UserID" under section "Login"
String userID = Misc.GetAppMapValue(Map.Login.UserID); //userID will be assigned as "xpath=foo"
String userID = Misc.GetAppMapValue(Map.Login.UserID, "result"); //get Map.Login.UserID and assign to variable "result"
String userID = Misc.GetAppMapValue(Map.Login.UserID, "", "false"); //get Map.Login.UserID without logging message
public static java.lang.String GetAppMapValue(java.lang.String contstant) throws SeleniumPlusException
contstant
- String, an constant name under the "ApplicationConstants"SeleniumPlusException
- if the parameter is null or the command was not executed successfully.
In base.map file, we have defined the followings
[ApplicationConstants]
Constant_A="Constant_A in base"
Constant_B="Constant_B in base"
[Login]
UserID="UserID in base"
In specific.map file, we have defined the followings
[ApplicationConstants]
Constant_A="Constant_A in specific"
[Login]
ChineseGUI="ChineseGUI"
String baseMap = "base.map";
String specificMap = "specific.map";
Misc.SetApplicationMap(baseMap);
Misc.SetApplicationMap(specificMap);
String value = null;
value = Misc.GetAppMapValue("Constant_A");//return "Constant_A in specific"
value = Misc.GetAppMapValue("Constant_B");//return "Constant_B in base"
Misc.CloseApplicationMap(specificMap);
value = Misc.GetAppMapValue("Constant_A");//return "Constant_A in base"
value = Misc.GetAppMapValue("Constant_B");//return "Constant_B in base"
public static java.lang.String GetAppMapValue(java.lang.String section, java.lang.String item) throws SeleniumPlusException
section
- String, a section name. If provide null, program will use default-section "ApplicationConstants".item
- String, an item name under the sectionSeleniumPlusException
- if the parameter is null or the command was not executed successfully.
In base.map file, we have defined the followings
[ApplicationConstants]
Constant_A="Constant_A in base"
Constant_B="Constant_B in base"
[Login]
UserID="UserID in base"
In specific.map file, we have defined the followings
[ApplicationConstants]
Constant_A="Constant_A in specific"
[Login]
ChineseGUI="ChineseGUI"
String baseMap = "base.map";
String specificMap = "specific.map";
Misc.SetApplicationMap(baseMap);
Misc.SetApplicationMap(specificMap);
String value = null;
value = Misc.GetAppMapValue("Login", "UserID");//return "UserID in base"
value = Misc.GetAppMapValue("Login", "ChineseGUI");//return "ChineseGUI"
value = Misc.GetAppMapValue((String)null, "Constant_A");//return "Constant_A in specific"
value = Misc.GetAppMapValue((String)null, "Constant_B");//return "Constant_B in base"
Misc.CloseApplicationMap(specificMap);
value = Misc.GetAppMapValue("Login", "UserID");//return "UserID in base"
value = Misc.GetAppMapValue("Login", "ChineseGUI");//return ""
value = Misc.GetAppMapValue((String)null, "Constant_A");//return "Constant_A in base"
value = Misc.GetAppMapValue((String)null, "Constant_B");//return "Constant_B in base"
public static int GetMillisBetweenRecords()
public static java.lang.String ResolveExpression(java.lang.String expression)
isExpressionsOn()
is true, the string will be resolved as "math" and "DDVariable"isExpressionsOn()
is false, the string will be resolved as "DDVariable"SAFSPlus.DriverCommand.Expressions(boolean)
, but sometimes we want to resolve an expression asSAFSPlus.DriverCommand.Expressions(boolean)
and call this method.expression
- String, the string to be resolved.isExpressionsOn()
,
String expression = "^var=3+5";
Misc.Expressions(true);
Misc.ResolveExpression(expression);//string "8" will be assigned to variable "var", and be returned as result.
Misc.Expressions(false);
Misc.ResolveExpression(expression);//string "3+5" will be assigned to variable "var", and be returned as result.
public static boolean IsComponentExists(Component component, java.lang.String... optionals)
component
- Component, The component to checkoptionals
- SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
//check if Basc_Button becomes valid within 15 seconds.
Misc.IsComponentExists(Map.SAPDemoPage.Basc_Button);
//check if Basc_Button becomes valid within 2 seconds.
Misc.IsComponentExists(Map.SAPDemoPage.Basc_Button, "2");
public static boolean isExpressionsOn() throws SeleniumPlusException
SeleniumPlusException
boolean originalExpressionOn = Misc.isExpressionsOn();
Misc.Expressions(false);
//Misc.Expressions(true);
//User do something with expression on/off
...
Misc.Expressions(originalExpressionOn);
public static boolean SwitchWindow(java.lang.String title, java.lang.String... optionals)
title
- String, the title of the window to switch to. It can be a normal string, a regexp string or a wildcard string.
If it is regexp/wildcard string, the optional parameters 'partialMatch' and 'ignoreCase' will be ignored.optionals
- SAFSPlus.prevResults
,
TestRecordData.getStatusCode()
,
//Switch to window with "Google" as title from within the last used browser.
Misc.SwitchWindow("Google");
//Switch to the first window with "Google" or "google" as title within the last used browser.
Misc.SwitchWindow("[G|g]oogle");
//Switch to the first window with "Google" as title within the browser opened with ID "TestGooglePage".
Misc.SwitchWindow("Google", "TestGooglePage");
//Switch to the 2th window with "Google" as title within the browser opened with ID "TestGooglePage".
Misc.SwitchWindow("Google", "TestGooglePage", "2");
//Switch to the 2th window with title containing "gle" within the browser opened with ID "TestGooglePage".
Misc.SwitchWindow("gle", "TestGooglePage", "2", "true");
//Switch to the 2th window with title containing "Goog" (case sensitive) within the browser opened with ID "TestGooglePage".
Misc.SwitchWindow("Goog", "TestGooglePage", "2", "true", "false");
Copyright © SAS Institute. All Rights Reserved.