public class ScriptingContextImpl extends ConcurrentHashMap implements ScriptingContext
T-Plan Robot Enterprise, (C) 2009-2022 T-Plan Limited. All rights reserved.
ConcurrentHashMap.KeySetView<K,V>
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
COMPARETO_CLICK_X, COMPARETO_CLICK_Y, COMPARETO_DISPLAY_NO, COMPARETO_PASS_RATE, COMPARETO_RESULT, COMPARETO_SORT_MODE, COMPARETO_SOURCE_X, COMPARETO_SOURCE_Y, COMPARETO_TEMPLATE, COMPARETO_TEMPLATE_HEIGHT, COMPARETO_TEMPLATE_INDEX, COMPARETO_TEMPLATE_WIDTH, COMPARETO_TIME_IN_MS, CONTEXT_CLI_VARIABLE_MAP, CONTEXT_CLIENT, CONTEXT_CODE_LINE_COUNTER, CONTEXT_COMMENT_LIST, CONTEXT_COMPILATION_ERRORS, CONTEXT_COMPILATION_FLAG, CONTEXT_COMPILER_PROGRESS, CONTEXT_CONNECT_THROWABLE, CONTEXT_CURRENT_DOCUMENT_ELEMENT, CONTEXT_CURRENT_DOCUMENT_ELEMENT_TEXT, CONTEXT_CURRENT_SCRIPT_WRAPPER, CONTEXT_DEBUG_MODE_FLAG, CONTEXT_DO_NOT_DESTROY_FLAG, CONTEXT_EVENT_SOURCE, CONTEXT_EXECUTION_DURATION, CONTEXT_EXECUTION_ERROR, CONTEXT_EXECUTION_LOG, CONTEXT_EXECUTION_START_DATE, CONTEXT_GOTO_TARGET_LABEL, CONTEXT_IMAGE_SEARCH_POINT_LIST, CONTEXT_INTERPRET, CONTEXT_LABEL_MAP, CONTEXT_LAST_EXECUTED_DOCUMENT_ELEMENT, CONTEXT_LAST_GENERATED_CLIENT_EVENT, CONTEXT_MASTER_INTERPRET, CONTEXT_MASTER_SCRIPT_WRAPPER, CONTEXT_OCR_LAST_TEXT, CONTEXT_OCR_LAST_TEXT_MAP, CONTEXT_OCR_LAST_TEXT_RECT, CONTEXT_OUTPUT_OBJECTS, CONTEXT_OUTPUT_PATH_ELEMENT, CONTEXT_OWNING_SCHEDULE, CONTEXT_PARSER, CONTEXT_PARTIAL_EXECUTION_END_REACHED, CONTEXT_PAUSE_REASON, CONTEXT_PROCEDURE_ARG_MAP, CONTEXT_PROCEDURE_DECLARATION_FLAG, CONTEXT_PROCEDURE_MAP, CONTEXT_PROGRAMMATIC_PAUSE_FLAG, CONTEXT_PROJECT_BEAN, CONTEXT_REPORT_ELEMENT, CONTEXT_REPORT_ELEMENT_LIST, CONTEXT_RFB_EVENT_LIST, CONTEXT_SAFEBOX, CONTEXT_SCRIPT_MANAGER, CONTEXT_SELECTED_DOCUMENT_ELEMENT, CONTEXT_STOP_REASON, CONTEXT_SUPPRESS_CLI_OUTPUT_FLAG, CONTEXT_TEMPLATE_META_DATA, CONTEXT_TEMPLATE_PATH_ELEMENT, CONTEXT_TIMER_MANAGER, CONTEXT_TPP_INTEGRATION_PARAM_MAP, CONTEXT_USER_CONFIGURATION, CONTEXT_VARIABLE_MAP, IMPLICIT_VARIABLE_BROWSER_CONTINUE, IMPLICIT_VARIABLE_CLICK_CONTINUE, IMPLICIT_VARIABLE_CURDATE, IMPLICIT_VARIABLE_CURDATE_FORMAT, IMPLICIT_VARIABLE_CURTIME, IMPLICIT_VARIABLE_DATESTAMP, IMPLICIT_VARIABLE_DESKTOP_HEIGHT, IMPLICIT_VARIABLE_DESKTOP_WIDTH, IMPLICIT_VARIABLE_DISPLAY, IMPLICIT_VARIABLE_DISPLAY_COUNT, IMPLICIT_VARIABLE_DISPLAY_H, IMPLICIT_VARIABLE_DISPLAY_W, IMPLICIT_VARIABLE_DISPLAY_X, IMPLICIT_VARIABLE_DISPLAY_Y, IMPLICIT_VARIABLE_DRAG_CONTINUE, IMPLICIT_VARIABLE_EXECUTION_SPEED_FACTOR, IMPLICIT_VARIABLE_EXIT_CODE, IMPLICIT_VARIABLE_EXIT_FAILED_ARGUMENT, IMPLICIT_VARIABLE_EXIT_FAILED_CMD, IMPLICIT_VARIABLE_EXIT_FAILED_LINE, IMPLICIT_VARIABLE_EXIT_FAILED_PARAMS, IMPLICIT_VARIABLE_EXIT_FAILED_SCRIPT, IMPLICIT_VARIABLE_EXIT_FAILED_TEMPLATE_SIZES, IMPLICIT_VARIABLE_EXIT_FAILED_TEMPLATES, IMPLICIT_VARIABLE_EXIT_SCREENSHOT, IMPLICIT_VARIABLE_FILE_NAME, IMPLICIT_VARIABLE_FILE_NAME_SHORT, IMPLICIT_VARIABLE_FILE_PATH_SEPARATOR, IMPLICIT_VARIABLE_FILE_SEPARATOR, IMPLICIT_VARIABLE_GEOMETRY, IMPLICIT_VARIABLE_INSTALL_DIR, IMPLICIT_VARIABLE_JAVA_VENDOR, IMPLICIT_VARIABLE_JAVA_VERSION, IMPLICIT_VARIABLE_LAST_CMP_COMMAND, IMPLICIT_VARIABLE_LAST_COMMAND, IMPLICIT_VARIABLE_MACHINE_NAME, IMPLICIT_VARIABLE_MOUSE_X, IMPLICIT_VARIABLE_MOUSE_Y, IMPLICIT_VARIABLE_PORT, IMPLICIT_VARIABLE_PROCEDURE_ARGUMENT_COUNT, IMPLICIT_VARIABLE_PRODUCT_HOME_PAGE, IMPLICIT_VARIABLE_PRODUCT_INSTALL_DIR, IMPLICIT_VARIABLE_PRODUCT_NAME, IMPLICIT_VARIABLE_PRODUCT_VERSION_LONG, IMPLICIT_VARIABLE_PRODUCT_VERSION_SHORT, IMPLICIT_VARIABLE_PROTOCOL, IMPLICIT_VARIABLE_RANDOM, IMPLICIT_VARIABLE_RANDOM_MAX, IMPLICIT_VARIABLE_RANDOM_MIN, IMPLICIT_VARIABLE_REPORT_DIR, IMPLICIT_VARIABLE_RGB, IMPLICIT_VARIABLE_RGB_X, IMPLICIT_VARIABLE_RGB_Y, IMPLICIT_VARIABLE_SCHEDULE_SEQ_NO, IMPLICIT_VARIABLE_SCRIPT_DIR, IMPLICIT_VARIABLE_SEARCH2_MAX_MATCHES, IMPLICIT_VARIABLE_SEQ_NO, IMPLICIT_VARIABLE_SERVER_CLIPBOARD_CONTENT, IMPLICIT_VARIABLE_SERVER_CLIPBOARD_CONTENT_TEXT, IMPLICIT_VARIABLE_SYSTEM_ARCITECTURE, IMPLICIT_VARIABLE_SYSTEM_NAME, IMPLICIT_VARIABLE_SYSTEM_VERSION, IMPLICIT_VARIABLE_TEMPLATE_DIR, IMPLICIT_VARIABLE_THREAD_ID, IMPLICIT_VARIABLE_TIMESTAMP, IMPLICIT_VARIABLE_URL, IMPLICIT_VARIABLE_WARNING_COUNT, REPORT_REPORT_DESC, REPORT_REPORT_FILE, REPORT_REPORT_FILENAME, REPORT_REPORT_RELATIVE_FILE, REPORT_STATUS_IMAGE_NAME, TRAILING_BACKSLASH_KEYWORD, WAITUNTIL_H, WAITUNTIL_TIMEOUT, WAITUNTIL_W, WAITUNTIL_X, WAITUNTIL_Y
Constructor and Description |
---|
ScriptingContextImpl()
Default parameterless constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addObjectListener(String key,
PropertyChangeListener l) |
void |
dispose()
Dispose (destroy) this context.
|
boolean |
equals(Object var1,
Object var2)
This method is provided to ensure compatibility of boolean expressions
converted from the scripting language.
|
RemoteDesktopClient |
getClient()
Get the current desktop client employed by the test script.
|
Map<String,String> |
getCommandLineVariables()
Get the map of override variables.
|
Number |
getComparisonResult()
Get a number representing result of the last performed image comparison
performed through the CompareTo or Screenshot commands.
|
List<SyntaxErrorException> |
getCompilationErrors()
Get the list of compilation errors in form of
SyntaxErrorException
instances. |
UserConfiguration |
getConfiguration()
Get shared instance of user configuration.
|
Throwable |
getConnectError()
Get the most recent throwable resulting from an attempt to connect to
a desktop.
|
Component |
getEventSource()
Get a dummy event source.
|
ScriptLogger |
getExecutionLog()
Get the execution log.
|
int |
getExitCode()
Get exit code of the last executed command.
|
TestScriptInterpret |
getInterpret()
Get the test script interpret associated with this context.
|
TestScriptInterpret |
getMasterInterpret()
Get the master test script interpret (the top level one) associated
with this context.
|
TestWrapper |
getMasterWrapper()
Get the master test wrapper.
|
Point |
getObjectSearchHit(int index)
Get the top left corner from the object search match of the specified index.
|
List<Rectangle> |
getObjectSearchRects()
Get the list of rectangles located through the Object Search image comparison
method.
|
List<Shape> |
getObjectSearchShapes()
Get the list of shapes located through the Object Search image comparison
method.
|
File |
getOutputDir()
Get the output directory.
|
List |
getOutputObjects()
Get the list of output objects.
|
TokenParser |
getParser()
Get an instance of the text parser.
|
com.tplan.robot.scripting.project.ProjectBean |
getProject()
Get the currently opened project.
|
static com.tplan.robot.scripting.project.ProjectBean |
getProject(File f)
Look for the project the argument file belongs to.
|
String |
getRecognizedText(Rectangle textRectangle)
Get the last text recognized from the desktop screen either using an OCR
engine (such as the Tesseract OCR comparison method)
or the Image Based Text Recognition.
|
Point |
getRecognizedTextClickPoint()
Get the center of the string located by the OCR.
|
LinkedHashMap<String,Rectangle> |
getRecognizedTextElements()
Get the map of text elements and their location in form of Rectangle objects
from the last text recognized from the desktop screen either using an OCR
engine or a similar image comparison method.
|
Color |
getRGB(int x,
int y)
Get the RGB color at the specified coordinates of the connected desktop.
|
String |
getRGBAsString(int x,
int y)
Get the RGB color at the specified coordinates of the connected desktop
in the 6-char HTML format (white="ffffff").
|
File |
getScriptFile() |
ScriptManager |
getScriptManager()
Get script manager owning the current test script.
|
Map |
getScriptParams()
Get the map of script parameters.
|
Point |
getSearchHitClickPoint()
Get the click point of the matching template image from the last image search.
|
Point |
getSearchHitClickPoint(int index)
Get the click point of matching template image of a particular index from
the last image search.It is an absolute point on the screen which defines
where to click on the match area.
|
List<Point> |
getSearchHits()
Get coordinates of template image occurences resulting from image comparison
performed through the
"search" method. |
Point |
getSearchHitSourcePoint()
Get the source point of the matching template image from the last image search.
|
File |
getSearchHitTemplateFile()
Get file of the matching template image in the last image search.
|
int |
getSearchHitTemplateIndex()
Get index of the matching template image from the last image search.
|
TemplateImageBean |
getSearchHitTemplateMetaData()
Get meta data container of the matching template image in the last image search.
|
Dimension |
getSearchHitTemplateSize()
Get size of the matching template image from the last image search.
|
List<Rectangle> |
getSearchRects()
Get the list of rectangular areas matched by the image search algorithm.
|
int |
getSeqNo()
Get the unique context's sequence number.
|
String |
getServerClipboardContent()
Get the latest clipboard text received from the desktop server.
|
String |
getServerClipboardContentAsText()
Get the latest clipboard text as received from the desktop server as
plain text.
|
File |
getTemplateDir()
Get the template directory.
|
Long |
getTimerValue(String timerName)
Get current value of a timer in milliseconds.
|
Object |
getVariable(String variableName)
Get value of a context variable.
|
Boolean |
getVariableAsBoolean(String variableName)
Convenience method to get a context variable as Boolean.
|
Color |
getVariableAsColor(String variableName)
Convenience method to get a context variable as Color.
|
Float |
getVariableAsFloat(String variableName)
Convenience method to get a context variable as Float number.
|
Integer |
getVariableAsInt(String variableName)
Convenience method to get a context variable as Integer number.
|
Point |
getVariableAsPoint(String variableName)
Convenience method to get a context variable as Point.
|
Rectangle |
getVariableAsRectangle(String variableName)
Convenience method to get a context variable as Rectangle.
|
String |
getVariableAsString(String variableName)
Convenience method to get a context variable as String.
|
ListenerMap<String,Object> |
getVariables()
Get the map with test script variables.
|
boolean |
isCompilationContext()
Indicate whether this context as a compilation one or execution one.
|
boolean |
isCompilationFinished()
Find out if the compilation process using this context has finished.
|
boolean |
isStructureRequired()
Find out if the script structure data should be collected during the
compilation process.
|
Boolean |
isTimerRunning(String timerName)
Find out whether a timer exists and is running (measuring time).
|
Object |
put(Object key,
Object value) |
boolean |
recordComment(Element comment)
Record a comment to the comment collection facility if it is supported
and enabled.
|
void |
removeObjectListener(PropertyChangeListener l) |
void |
removeVariables(Object... patterns)
Remove variables that meet the given name(s) (String arguments) or
matches the given regular expression (s) (
Pattern
arguments).If the name is a String and contains the parameter
{0} it will be replaced with numbers starting from 0 using
MessageFormat and all variables that meet the name will
be removed. |
String |
resolveVariable(String name)
Look up the variable value.
|
void |
setOutputDir(File directory)
Set the output directory.
|
void |
setTemplateDir(File directory)
Set the template directory.
|
void |
setVariable(String variableName,
Object value)
Set a context variable.
|
clear, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, forEach, forEach, forEachEntry, forEachEntry, forEachKey, forEachKey, forEachValue, forEachValue, get, getOrDefault, hashCode, isEmpty, keys, keySet, keySet, mappingCount, merge, newKeySet, newKeySet, putAll, putIfAbsent, reduce, reduceEntries, reduceEntries, reduceEntriesToDouble, reduceEntriesToInt, reduceEntriesToLong, reduceKeys, reduceKeys, reduceKeysToDouble, reduceKeysToInt, reduceKeysToLong, reduceToDouble, reduceToInt, reduceToLong, reduceValues, reduceValues, reduceValuesToDouble, reduceValuesToInt, reduceValuesToLong, remove, remove, replace, replace, replaceAll, search, searchEntries, searchKeys, searchValues, size, toString, values
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
public ScriptingContextImpl()
public void addObjectListener(String key, PropertyChangeListener l)
addObjectListener
in interface ScriptingContext
public void removeObjectListener(PropertyChangeListener l)
removeObjectListener
in interface ScriptingContext
public Object put(Object key, Object value)
put
in interface Map
put
in class ConcurrentHashMap
public RemoteDesktopClient getClient()
getClient
in interface ScriptingContext
public UserConfiguration getConfiguration()
getConfiguration
in interface ScriptingContext
public ScriptManager getScriptManager()
getScriptManager
in interface ScriptingContext
public ListenerMap<String,Object> getVariables()
getVariables
in interface ScriptingContext
public Map getScriptParams()
ScriptingContext
getScriptParams
in interface ScriptingContext
public TokenParser getParser()
ScriptingContext
getParser
in interface ScriptingContext
public void setVariable(String variableName, Object value)
ScriptingContext
Set a context variable.
The context stores a map of
variables ([variable_name, variable_alue] pairs) under the ScriptingContext.CONTEXT_VARIABLE_MAP
key.
While the Var and Eval commands create entries
in this map, a preprocessor of the proprietary test script interpret
ProprietaryTestScriptInterpret
makes sure that any variable reference
in form of {variable_name}
in a test script command line
gets replaced with the variable value before further processing.
The variable map is available through the ScriptingContext.getVariables()
method.
As it is a ListenerMap
instance, anyone may
register for variable change events through the ListenerMap.addPropertyChangeListener(java.beans.PropertyChangeListener)
listener interface.
setVariable
in interface ScriptingContext
variableName
- a variable name (case sensitive).value
- variable value, usually a String (created through Var
)
or a Number (typically defined by Eval
) instance.public Object getVariable(String variableName)
ScriptingContext
Get value of a context variable.
The context stores a map of
variables ([variable_name, variable_alue] pairs) under the ScriptingContext.CONTEXT_VARIABLE_MAP
key.
While the Var and Eval commands create entries
in this map, a preprocessor of the proprietary test script interpret
ProprietaryTestScriptInterpret
makes sure that any variable reference
in form of {variable_name}
in a test script command line
gets replaced with the variable value before further processing.
The variable map is available through the ScriptingContext.getVariables()
method.
As it is a ListenerMap
instance, anyone may
register for variable change events through the ListenerMap.addPropertyChangeListener(java.beans.PropertyChangeListener)
listener interface.
getVariable
in interface ScriptingContext
variableName
- a case sensitive variable name to retrieve the value of.Var
)
or a Number (typically defined by Eval
) instance. The method returns
null if the variable doesn't exist.public String resolveVariable(String name)
ScriptingContext
resolveVariable
in interface ScriptingContext
name
- a variable name.public int getExitCode()
ScriptingContext
getExitCode
in interface ScriptingContext
public File getScriptFile()
public File getOutputDir()
ScriptingContext
Get the output directory. It is a folder where output objects such as screen shots, files and reports should be saved to unless the test script code specifies otherwise (for example through specifying an output object with an absolute path pointing somewhere else).
Default value returned by the method is the user home folder obtained from the JVM system
properties as System.getProperty("user.dir")
. This default
value may be overriden through the scripting.defaultOutputPath
user preference. See the UserConfiguration
class for more.
The output path may be customized for a particular test script programatically
through the ScriptingContext.setOutputDir(java.io.File)
method or through setting of the _REPORT_DIR
context variable in a test script.
The new path is however not applied to the objects which have been created
before the change. To make sure that all output goes to one custom directory set the
output path at the very beginning of your test script.
As the method is just a convenience method which returns value of the
_REPORT_DIR
context variable, objects interested in receiving
events about the path update may take advantage of the ListenerMap
interface of the map of context variables
to register
for the variable changes.
getOutputDir
in interface ScriptingContext
public void setOutputDir(File directory)
ScriptingContext
Set the output directory. It is a folder where output objects such as screenshots, files and reports should be saved to unless the test script code specifies otherwise (for example through specifying an output object with an absolute path pointing somewhere else).
This is just a convenience method which sets the _REPORT_DIR
context variable through the ScriptingContext.setVariable(java.lang.String, java.lang.Object)
method.
A null value will reset the path to the default value described in the ScriptingContext.getOutputDir()
method.
Be aware that the new path is not applied to the objects which have been created before the change. To make sure that all output goes to one custom directory set the output path at the very beginning of your test script.
setOutputDir
in interface ScriptingContext
directory
- a new output path or null to reset the directory to the default value.public File getTemplateDir()
ScriptingContext
Get the template directory. It is a folder where commands performing image comparison will look for template images unless the command parameter specifies the template with a full path.
Default value returned by the method is the user home folder obtained from the JVM system
properties as System.getProperty("user.dir")
. This default
value may be overriden through the scripting.defaultTemplatePath
user preference. See the UserConfiguration
class.
The template path may be customized for a particular test script programatically
through the ScriptingContext.setTemplateDir(java.io.File)
method or through setting of the _TEMPLATE_DIR
context variable
in the test script.
As the method is just a convenience method which returns value of the
_TEMPLATE_PATH
context variable, objects interested in receiving
events about the path update may take advantage of the ListenerMap
interface of the map of context variables
to register
for the variable changes.
getTemplateDir
in interface ScriptingContext
public void setTemplateDir(File directory)
ScriptingContext
Set the template directory. It is a folder where commands performing image comparison will look for template images unless the command parameter specifies the template with a full path.
This is just a convenience method which sets the _TEMPLATE_DIR
context variable through the ScriptingContext.setVariable(java.lang.String, java.lang.Object)
method.
A null value will reset the path to the default value described in the ScriptingContext.getTemplateDir()
method.
setTemplateDir
in interface ScriptingContext
directory
- a new path to read template images from.public String getServerClipboardContent()
ScriptingContext
Get the latest clipboard text received from the desktop server. This is
just a convenience method which returns value of the _SERVER_CLIPBOARD_CONTENT
context variable and it is equivalent to (String)getVariable("_SERVER_CLIPBOARD_CONTENT")
.
The method returns a non null method only if (1) a desktop is connected,
(2) both the desktop server and client support clipboard content transfer and
(3) the client has received which the user has cut or copied text on the desktop.
To find out whether the current client (ScriptingContext.getClient()
) supports clipboard
transfers at all check whether it implements the ClipboardTransferCapable
capability.
For example, an RFB (VNC) server does support clipboard transfer provided
that either the vncconfig
or other clipboard
handling utility (autocutsel, ...) is
running on the server. When user copies/cuts a text on the desktop using
Ctrl+C or Ctrl+X, it gets transferred to the client which is expected to update the
_SERVER_CLIPBOARD_CONTENT
context variable.
To wait for a clipboard change in a test script use the Waitfor clipboard command.
To register programatically as a listener for clipboard changes either use the
RemoteDesktopClient.addServerListener(com.tplan.robot.remoteclient.RemoteDesktopServerListener)
interface and check for the RemoteDesktopServerEvent.SERVER_CLIPBOARD_EVENT
event type, or
register as a listener to the variable map (see ScriptingContext.getVariables()
description).
The difference is that while one test script uses the same context during
the whole script execution, the client may change as with the connect and
disconnect command calls of the test script code.
getServerClipboardContent
in interface ScriptingContext
public String getServerClipboardContentAsText()
ScriptingContext
ScriptingContext.getServerClipboardContent()
save that if the returned text is an
HTML document or a chunk of HTML code it gets converted to plain text.getServerClipboardContentAsText
in interface ScriptingContext
public List<Point> getSearchHits()
ScriptingContext
Get coordinates of template image occurences resulting from image comparison
performed through the "search"
method. This list is populated by
the built-in image search plugin SearchImageComparisonModule
every
time its compare()
or
compareToBaseImage()
method
gets invoked.
This method belongs to convenience methods allowing to access image
search results on the Java API level. Image search is usually triggered
by one of the test script commands (methods) such as compareTo(),
screenshot(), waitForMatch() or waitForMismatch() from the DefaultJavaTestScript
class. The algorithm accepts one or more template images on input and
searches desktop of the currently connected client (see ScriptingContext.getClient()
)
for matching areas. The input images are processed one by one
in the order they were specified at and the search is stopped when
at least one match is found or the end of the image list is achieved.
Result of image search is primarily expressed by the calling method's
numeric exit code and additional information (such as match coordinates and
matching template details) are stored to the context in form of variables
(see the ScriptingContext.getVariable(java.lang.String)
method). To avoid casting
and conversion of variables to numeric values the context provides the
following set of convenience methods:
ScriptingContext.getComparisonResult()
returns in case of image search either
0 (meaning "no matches found") or 100 (meaning "at least one match was found").ScriptingContext.getSearchHits()
returns the list of match locations (left upper
corner of the match area on the desktop).ScriptingContext.getSearchHitTemplateIndex()
returns index of the matching
template in the input list.ScriptingContext.getSearchHitTemplateFile()
returns the matching template file (if available).ScriptingContext.getSearchHitTemplateSize()
returns size (width and height)
of the matching template.ScriptingContext.getSearchHitTemplateMetaData()
returns the image meta data container.getSearchHits
in interface ScriptingContext
public Component getEventSource()
ScriptingContext
java.awt.Component
event source in the constructor, the component returned by this method is
used as event source by some framework classes which use the Java event
system but are not Component instances.getEventSource
in interface ScriptingContext
public TestWrapper getMasterWrapper()
ScriptingContext
getMasterWrapper
in interface ScriptingContext
ScriptWrapper
instance (when the
test script is a proprietary one) or DefaultJavaTestScript
when the test script is a Java one.public Map<String,String> getCommandLineVariables()
ScriptingContext
-v/--variable
command line parameters. They override values
of variables specified in scripts. See the CLI Options documentation on
how to override script variables.getCommandLineVariables
in interface ScriptingContext
public Number getComparisonResult()
ScriptingContext
Get a number representing result of the last performed image comparison performed through the CompareTo or Screenshot commands. It is a number between 0 and 100 representing percentage of how much the two compared images matched. The value is subject to the image comparison method used; image search for example returns either 0 (meaning "no matches found") or 100 (meaning "at least one match was found") while the "default" histogram based method returns any number between 0 and 100 reflecting the percentage of matching pixels.
getComparisonResult
in interface ScriptingContext
public boolean isCompilationContext()
ScriptingContext
isCompilationContext
in interface ScriptingContext
public TestScriptInterpret getInterpret()
ScriptingContext
getInterpret
in interface ScriptingContext
public List<SyntaxErrorException> getCompilationErrors()
ScriptingContext
SyntaxErrorException
instances.getCompilationErrors
in interface ScriptingContext
public List getOutputObjects()
ScriptingContext
getOutputObjects
in interface ScriptingContext
public void dispose()
ScriptingContext
dispose
in interface ScriptingContext
public Throwable getConnectError()
ScriptingContext
getConnectError
in interface ScriptingContext
public int getSearchHitTemplateIndex()
ScriptingContext
ScriptingContext.getSearchHits()
method documentation for more.getSearchHitTemplateIndex
in interface ScriptingContext
public Dimension getSearchHitTemplateSize()
ScriptingContext
ScriptingContext.getSearchHits()
method documentation for more.getSearchHitTemplateSize
in interface ScriptingContext
public File getSearchHitTemplateFile()
ScriptingContext
getSearchHitTemplateFile
in interface ScriptingContext
DefaultJavaTestScript.compareTo(java.awt.Image[], com.tplan.robot.imagecomparison.ImageComparisonModule, float, java.awt.Rectangle)
method).public TemplateImageBean getSearchHitTemplateMetaData()
ScriptingContext
ScriptingContext.getSearchHits()
method documentation for more.getSearchHitTemplateMetaData
in interface ScriptingContext
DefaultJavaTestScript.compareTo(java.awt.Image[], com.tplan.robot.imagecomparison.ImageComparisonModule, float, java.awt.Rectangle)
method).public Point getSearchHitClickPoint()
ScriptingContext
Get the click point of the matching template image from the last image search. It is an absolute point on the screen which defines where to click on the match area. It usually defaults to the template image center.
Do not confuse this method with the TemplateImageBean.getClickPoint()
one which returns relative [x, y] in the template image coordinate system.
The getSearchHitClickPoint()
rather returns a "ready to be used"
click point which was calculated with regard to the specific match location.
getSearchHitClickPoint
in interface ScriptingContext
public Point getSearchHitClickPoint(int index)
ScriptingContext
Get the click point of matching template image of a particular index from the last image search.It is an absolute point on the screen which defines where to click on the match area. It usually defaults to the template image center.
Do not confuse this method with the
TemplateImageBean.getClickPoint()
one which returns relative [x,
y] in the template image coordinate system. The
getSearchHitClickPoint()
rather returns a "ready to be used"
click point which was calculated with regard to the specific match
location.
getSearchHitClickPoint
in interface ScriptingContext
index
- index of the search match.public Point getSearchHitSourcePoint()
ScriptingContext
getSearchHitSourcePoint
in interface ScriptingContext
public Integer getVariableAsInt(String variableName)
ScriptingContext
ScriptingContext.getVariable(java.lang.String)
)
and converts it to integer using the methods of the shared parser (see ScriptingContext.getParser()
).getVariableAsInt
in interface ScriptingContext
variableName
- variable name (case sensitive).IllegalArgumentException
.
If the variable doesn't exist, the method returns null.public Float getVariableAsFloat(String variableName)
ScriptingContext
ScriptingContext.getVariable(java.lang.String)
)
and converts it to float using the methods of the shared parser (see ScriptingContext.getParser()
).getVariableAsFloat
in interface ScriptingContext
variableName
- variable name (case sensitive).IllegalArgumentException
.
If the variable doesn't exist, the method returns null.public Boolean getVariableAsBoolean(String variableName)
ScriptingContext
ScriptingContext.getVariable(java.lang.String)
)
and converts it to boolean using the methods of the shared parser (see ScriptingContext.getParser()
).getVariableAsBoolean
in interface ScriptingContext
variableName
- variable name (case sensitive).IllegalArgumentException
.
If the variable doesn't exist, the method returns null.public String getVariableAsString(String variableName)
ScriptingContext
ScriptingContext.getVariable(java.lang.String)
)
and converts it to string using the Object.toString()
method..getVariableAsString
in interface ScriptingContext
variableName
- variable name (case sensitive).public Point getVariableAsPoint(String variableName)
ScriptingContext
ScriptingContext.getVariable(java.lang.String)
)
and makes an attempt to convert it to a Point
using
the shared parser (see ScriptingContext.getParser()
). The variable value format must be compliant
with the Point expression described in the scripting language specification. For example,
a point of (10,20) is represented by a value like "x:10,y:20".getVariableAsPoint
in interface ScriptingContext
variableName
- variable name (case sensitive).IllegalArgumentException
.
If the variable doesn't exist, the method returns null.public Rectangle getVariableAsRectangle(String variableName)
ScriptingContext
ScriptingContext.getVariable(java.lang.String)
)
and makes an attempt to convert it to a Rectangle
using
the shared parser (see ScriptingContext.getParser()
). The variable value format must be compliant
with the Rectangle expression described in the scripting language specification. For example,
a rectangle with the left upper corner at (10,20) and the size (width,height) equal
to (100,200) is represented by a value like "x:10,y:20,w:100,h:200".getVariableAsRectangle
in interface ScriptingContext
variableName
- variable name (case sensitive).IllegalArgumentException
.
If the variable doesn't exist, the method returns null.public Color getVariableAsColor(String variableName)
ScriptingContext
ScriptingContext.getVariable(java.lang.String)
)
and makes an attempt to convert it to a Color
using
the shared parser (see ScriptingContext.getParser()
). The variable value format must be compliant
with the HTML-like color expression format described in the scripting language specification. For example,
a color of (R,G,B) equal to (0,128,256) is represented by a value like "0080FF".getVariableAsColor
in interface ScriptingContext
variableName
- variable name (case sensitive).IllegalArgumentException
.
If the variable doesn't exist, the method returns null.public List<Shape> getObjectSearchShapes()
ScriptingContext
Shape.getBounds()
method.getObjectSearchShapes
in interface ScriptingContext
public Point getObjectSearchHit(int index)
ScriptingContext
ArrayIndexOutOfBoundsException
if the index is >=
the number of matches.getObjectSearchHit
in interface ScriptingContext
index
- index (the first match has the index of 0).public TestScriptInterpret getMasterInterpret()
ScriptingContext
getMasterInterpret
in interface ScriptingContext
public Long getTimerValue(String timerName)
ScriptingContext
Get current value of a timer in milliseconds. If the timer doesn't exist (meaning
it hasn't been created by a call of Timer command or a call of
DefaultJavaTestScript.timer(java.lang.String, java.lang.String, java.lang.String, long, long, java.lang.String, java.lang.String, java.io.File)
or any other similar timer method), the method returns null.
To format the value into a displayable string you may take advantage
of Utils.getTimePeriodForDisplay(long, boolean)
, Utils.getTimePeriodForDisplay(long, boolean, boolean)
or Utils.getTimePeriodForDisplay(long, boolean, boolean, boolean)
.
getTimerValue
in interface ScriptingContext
timerName
- timer name (case sensitive).public Boolean isTimerRunning(String timerName)
ScriptingContext
DefaultJavaTestScript.timer(java.lang.String, java.lang.String, java.lang.String, long, long, java.lang.String, java.lang.String, java.io.File)
or any other similar timer method), the method returns null. Otherwise the
method returns a valid Boolean value indicating whether the timer is started or not.isTimerRunning
in interface ScriptingContext
timerName
- timer name (case sensitive).public boolean equals(Object var1, Object var2)
ScriptingContext
true
if the objects represent equal numbers (even in form of
String instances) or if the objects are equal strings.
For example, equals("3", "3.0")
will return true because the
both arguments may be converted to numbers whose values are equal.equals
in interface ScriptingContext
var1
- first variable value.var2
- another variable value.public boolean recordComment(Element comment)
recordComment
in interface ScriptingContext
comment
- a comment.public List<Rectangle> getSearchRects()
ScriptingContext
ScriptingContext.getSearchHits()
method where each match location (Point instance)
is combined with the matching template image size returned by ScriptingContext.getSearchHitTemplateSize()
to produce a Rectangle representing the matching area on the screen.getSearchRects
in interface ScriptingContext
public List<Rectangle> getObjectSearchRects()
ScriptingContext
ScriptingContext.getObjectSearchShapes()
method where each Shape is converted to a
rectangle using Shape.getBounds()
.getObjectSearchRects
in interface ScriptingContext
public ScriptLogger getExecutionLog()
ScriptingContext
getExecutionLog
in interface ScriptingContext
public Color getRGB(int x, int y)
ScriptingContext
ArrayIndexOutOfBoundsException
if the coordinates are out of bounds.getRGB
in interface ScriptingContext
x
- the X-coordinate within [0, desktopWidth-1].y
- the Y-coordinate within [0, desktopHeight-1].public String getRGBAsString(int x, int y)
ScriptingContext
ArrayIndexOutOfBoundsException
if the coordinates are out of bounds.getRGBAsString
in interface ScriptingContext
x
- the X-coordinate within [0, desktopWidth-1].y
- the Y-coordinate within [0, desktopHeight-1].public String getRecognizedText(Rectangle textRectangle)
ScriptingContext
getRecognizedText
in interface ScriptingContext
textRectangle
- optional Rectangle instance to store the text rectangle to. If the
source OCR doesn't support extraction of the text coordinates it will set
the rectangle width and height to 0.public LinkedHashMap<String,Rectangle> getRecognizedTextElements()
ScriptingContext
getRecognizedTextElements
in interface ScriptingContext
public com.tplan.robot.scripting.project.ProjectBean getProject()
ScriptingContext
getProject
in interface ScriptingContext
public static com.tplan.robot.scripting.project.ProjectBean getProject(File f)
f
- a file.public Point getRecognizedTextClickPoint()
ScriptingContext
ScriptingContext.getRecognizedText(java.awt.Rectangle)
method.getRecognizedTextClickPoint
in interface ScriptingContext
public int getSeqNo()
ScriptingContext
getSeqNo
in interface ScriptingContext
public boolean isStructureRequired()
isStructureRequired
in interface ScriptingContext
public boolean isCompilationFinished()
ScriptingContext
isCompilationFinished
in interface ScriptingContext
public void removeVariables(Object... patterns)
ScriptingContext
Pattern
arguments).If the name is a String and contains the parameter
{0}
it will be replaced with numbers starting from 0 using
MessageFormat
and all variables that meet the name will
be removed.removeVariables
in interface ScriptingContext
patterns
- variable names of patterns.