![]() |
T-Plan
Robot Enterprise Plugin Home |
14 June 2018 |
To install the plugin download the appropriate archive from the
following location:
OPTION 1:
IMPORTANT: As Java 9 broke
support of dynamic JAR loading you must use this option if you are
running Java 9 or higher.
tablekit.jar
file to the class path of
the Robot start command. For details see the Robot release
notes.
OPTION 2 (JAVA 8 AND LOWER):
plugins/
directory under
the Robot installation directory. This will make Robot load the
classes on the start up. Make sure to remove any older versions
of the plugin.
OPTION 3 (JAVA 8 AND LOWER):
NOTE: This option will not install the table viewer into
the menu. The viewer will be however available from the Properties
window of the GetTables script. For the
viewer screenshot see the Usage chapter
below.
Include
"<location>/tablekit.jar"
tablekit.jar
file onto the Java class path (see OPTION 1).
Script Name
Description
com.tplan.table.GetTables
Recognize table(s) on the screen.
com.tplan.table.GetCell
Retrieve information of a cell of the previously recognized table.
com.tplan.table.ExportTable
Export previously recognized table to a text, CSV or MS Excel file.
The plugin scripts are to be called from TPR test scripts using
the Run
command. The command instances may be easily created using
the Command
Wizard tool. To edit an existing Run command right click it
and select Properties in the context menu. The GetTable
script also provides the table viewer:
A few examples showing typical usage:
EXAMPLE #1: Recognize a table and save text of its cell at the second row and third column to a variable called TEXT:
// Presume that tablekit.jar is in the script folder
Include "tablekit.jar"
// Recognize table(s) on the screen
Run "com.tplan.table.GetTables"
if ({_EXIT_CODE} > 0) {
Exit 1 desc="No tables were found."
}
// Get details of the cell at row=2 and column=3 and perform OCR
Run "com.tplan.table.GetCell" row="2" column="3" tocr="true"
if ({_EXIT_CODE} > 0) {
Exit 2 desc="Failed to retrieve cell at [2,3]. See the log for details."
}
// Save the cell text to the TEXT variable
Var TEXT= "{_TABLE_CELL_TEXT}"
EXAMPLE #2: Click cell at
[row, column] = [3,5].
// Recognize table(s) on the screen
Run "com.tplan.table.GetTables"
if ({_EXIT_CODE} > 0) {
Exit 1 desc="No tables were found."
}
// Get coordinates of the cell at [3,5]
Run "com.tplan.table.GetCell" row="3" column="5"
if ({_EXIT_CODE} > 0) {
Exit 2 desc="Failed to retrieve cell at [3,5]. See the log for details."
}
// Click at the cell coordinates plus 5 pixels in each direction
Mouse click to="x:{_TABLE_CELL_X}+5,y:{_TABLE_CELL_Y}+5"
EXAMPLE #3: Verify whether the
cells in the first column have the same color and set the
SAMECOLOR variable to true or false accordingly.
EXAMPLE #4: Recognize table(s) and save them to a MS Excel file.
// Declare the _TABLE1_ROWS variable to suppress compiler warnings in for()
Var _TABLE1_ROWS =0
// Recognize table(s) on the screen
Run "com.tplan.table.GetTables"
if ({_EXIT_CODE} > 0) {
Exit 1 desc="No tables were found."
}
// Get color of the first cell
Run "com.tplan.table.GetCell"
if ({_EXIT_CODE} > 0) {
Exit 2 desc="Failed to retrieve cell at [1,1]. See the log for details."
}
Var COLOR ={_TABLE_CELL_COLOR}
// Iterate over the rest of cells in the first column and test
// whether their color is the same
Var SAMECOLOR =true
for (i=2; {i}<{_TABLE1_ROWS}+1; i={i}+1) {
Run "com.tplan.table.GetCell" row={i} column=1
if ("{_TABLE_CELL_COLOR}" != "{COLOR}") {
// Not the same color
Var SAMECOLOR =false
break
}
}
// Recognize tables and perform OCR to retrieve text of all cells
Run "com.tplan.table.GetTables" tocr="true"
if ({_EXIT_CODE} > 0) {
Exit 1 desc="No tables were found."
}
// Export the tables to MS Excel
Run "com.tplan.table.ExportTable" file="C:\test.xlsx"
DESCRIPTION |
|
NOTE: The parameter of scale is obsoleted since v0.5. It is accepted on the command line to preserve compatibility with the previous releases but its value is ignored. The command will identify the best scaling factor on its own.
Variable Name
Description _TABLE_COUNT=<number>
Number of recognized tables.
_TABLE<n>_X=<X-coordinate>
_TABLE<n>_Y=<Y-coordinate>
_TABLE<n>_W=<width>
_TABLE<n>_H=<height>
The bounding rectangle of the n-th table where <n> is between one and
the number of tables.
_TABLE<n>_ROWS=<number>
_TABLE<n>_COLUMNS=<number>
_TABLE<n>_CELLS=<number>
Number or rows, columns and cells of the n-th table where <n> is between
one and the number of tables._TABLE<n>_TEXT=<number> Summary text recognized in the n-th table. This variable is populated only
if the OCR is on (tocr=true). The text is composed of the individual cells
in the reading mode with the tabulator (tab, \t) and new line (\n) serving as
the cell and row separators.
To get text of a single cell use GetCell.
- Minimum cell height in pixels. Defaults to 10.
- Minimum required number of table rows. Tables that don't meet this criteria will be omitted. Defaults to 2 rows.
- Minimum required number of table columns. Tables that don't meet this criteria will be omitted. Defaults to 2 columns.
- Maximum spacing (grid thickness) between two neighboring cells. Defaults to 4 pixels.cmparea=[x:<x>][,y:<y>][,w:<width>][,h:<height>]
- The rectangular area of the desktop to limit the table recognition to. The syntax and functionality is equal to the cmparea parameter of the CompareTo command. If you omit this parameter the whole remote desktop will be processed. The area coordinates have format of 'x:<x>,y:<y>,w:<width>,h:<height>
', where each coordinate can be specified in pixels (for example."x:225"
) or as a percentage ("x:23%"
).
If any of x, y, width or height are omitted, T-Plan Robot will use the full screen values to determine the missing parameters (x:0, y:0, w:<screen_width>, h:<screen_height>
). For example,"cmparea=y:50%,height:50%"
will process bottom half of the screen.
tocr=<true|false>
"true"
will perform Tesseract OCR for each recognized cell to retrieve
its text. The text may be then obtained through a call of the GetCell script. The parameter defaults to false
(do not perform OCR).language=<lang_code>
fixocr=<true|false>
true
will make an attempt to fix some known Tesseract OCR accuracy
errors such as:true
(do fix). Set it off if
the command fixes texts that are not supposed to be fixed, such as
strings similar to numbers or dates (product codes, special char
and digit sequences...)RETURNS
The command returns 0 (zero) when at least one table is found
and no error is experienced. Otherwise it returns 1 (one) when no
tables get recognized or 2 (two) when the OCR fails to execute for
an I/O error, typically when Tesseract is not installed or
misconfigured. The failure is also logged into the execution log.
2
GetCell ScriptDESCRIPTION |
|
NOTE: The parameter of scale is obsoleted since v0.5. It is accepted on the command line to preserve compatibility with the previous releases but its value is ignored. The command will identify the best scaling factor on its own.
Variable Name
Description _TABLE_CELL_X=<X-coordinate>
_TABLE_CELL_Y=<Y-coordinate>
_TABLE_CELL_W=<width>
_TABLE_CELL_H=<height>
The bounding rectangle of the cell.
_TABLE_CELL_ROWSPAN=<number>
_TABLE_CELL_COLSPAN=<number>
The cell row span and cell span. _TABLE_CELL_TEXT=<number> The cell text. This variable is populated only if the OCR is on (tocr=true) or if OCR
has been performed before either by GetTables or by a call of GetCell for the same
cell row and column number.
_TABLE_CELL_BLANK=<true|false> Indicates whether the cell is blank or not. This is verified independently from OCR
through testing whether the cell area is made of a single color.
_TABLE_CELL_COLOR=<color> The cell background color in the HTML notation. For example, white is "ffffff" while
black is "000000".
column=<number>
table=<number>
tocr=<true|false>
- The value of"true"
will perform Tesseract OCR to retrieve the cell text unless the cell is blank (solid color). The parameter defaults to false (do not perform OCR).
language=<lang_code>
- A valid 3-character language code of a properly installed Tesseract language data file. The parameter is used only if OCR is on (tocr=true). If the parameter is omitted it defaults to "eng" (English). See the Tesseract OCR comparison method for details.
fixocr=<true|false>
true
will make an attempt to fix some known Tesseract OCR accuracy
errors such as:true
(do fix). Set it off if
the command fixes texts that are not supposed to be fixed, such as
strings similar to numbers or dates (product codes, special char
and digit sequences...)RETURNS
The command returns 0 (zero) on success. When it fails it
returns 1 (one) when the cell is not available or 2 (two) when the
OCR fails to execute for an I/O error, typically when Tesseract is
not installed or misconfigured. The failure is
also logged into the execution
log.
EXAMPLES
See the Usage chapter.
ExportTable ScriptDESCRIPTION |
|
tocr=true
).
A typical sequence of commands to recognize table(s) and store them
to a MS Excel file is:// Recognize tables and perform OCR to retrieve text of all cells
Run "com.tplan.table.GetTables" tocr="true"
if ({_EXIT_CODE} > 0) {
Exit 1 desc="No tables were found."
}
// Export the tables to MS Excel
Run "com.tplan.table.ExportTable" file="C:\test.xlsx"
tables=<number(s)>
RETURNS
The command returns 0 (zero) on success. It returns 1 (one)
when it fails for an I/O error or if the table list is invalid.
The failure is also logged into the execution log.
EXAMPLES
See the Usage chapter.
Version 0.7 released on 14 June 2018
Version 0.6 released on 15 November 2016
Version 0.5 released on 19 June 2014