This library wraps the upstream [https://frankvanderkuur.github.io/SapGuiLibrary.html|SapGuiLibrary].
The SapGuiLibrary is a library that enables users to create tests for the Sap Gui application
The library uses the Sap Scripting Engine, therefore Scripting must be enabled in Sap in order for this library to work.
= Opening a connection / Before running tests =
First of all, you have to make sure the Sap Logon Pad is started. You can automate this process by using the AutoIT library or the Process Library.
After the Sap Login Pad is started, you can connect to the Sap Session using the keyword connect to session.
If you have a successful connection you can use Open Connection to open a new connection from the Sap Logon Pad or Connect To Existing Connection to connect to a connection that is already open.
= Locating or specifying elements =
You need to specify elements starting from the window ID, for example, wnd/tbar/btn. In some cases the SAP ID contains backslashes. Make sure you escape these backslashes by adding another backslash in front of it.
= Screenshots (on error) =
The SapGUILibrary offers an option for automatic screenshots on error. Default this option is enabled, use keyword disable screenshots on error to skip the screenshot functionality. Alternatively, this option can be set at import.
Performs a single click on a given element. Used only for buttons, tabs and menu items.
In case you want to change a value of an element like checkboxes of selecting an option in dropdown lists, use select checkbox or select from list by label instead.
Clicks a button of a toolbar within a GridView ‘table_id’ which is contained within a shell object. Use the Scripting tracker recorder to find the ‘button_id’ of the button to click
Connects to an open connection. If the connection matches the given connection_name, the session is connected to this connection.
Connects to an open session SAP.
See Opening a connection / Before running tests for details about requirements before connecting to a session.
Optionally set explicit wait can be used to set the explicit wait time.
Examples: | Keyword | Attributes | | connect to session | | | connect to session | 3 | | connect to session | explicit_wait=500ms |
Disables automatic screenshots on error.
doubleclick_element(element_id, item_id, column_id)¶
Performs a double-click on a given element. Used only for shell objects.
Checks whether an element is present on the screen.
element_value_should_be(element_id, expected_value, message=None)¶
Checks whether the element value is the same as the expected value. The possible expected values depend on the type of element (see usage).
Usage: | Element type | possible values | | textfield | text | | label | text | | checkbox | checked / unchecked | | radiobutton | checked / unchecked | | combobox | text of the option to be expected |
element_value_should_contain(element_id, expected_value, message=None)¶
Checks whether the element value contains the expected value. The possible expected values depend on the type of element (see usage).
Usage: | Element type | possible values | | textfield | text | | label | text | | combobox | text of the option to be expected |
Enables automatic screenshots on error.
get_cell_value(table_id, row_num, col_id)¶
Returns the cell value for the specified cell.
Returns the Sap element location for the given element.
Returns the Sap element type for the given element.
Returns the number of rows found in the specified table.
Returns the scroll position of the scrollbar of an element ‘element_id’ that is contained within a shell object.
Gets the value of the given element. The possible return values depend on the type of element (see Return values).
Return values: | Element type | Return values | | textfield | text | | label | text | | checkbox | checked / unchecked | | radiobutton | checked / unchecked | | combobox | text of the selected option | | guibutton | text | | guititlebar | text | | guistatusbar | text | | guitab | text |
Retrieves the window title of the given window.
Inserts the given password into the text field identified by locator. The password is not recorded in the log.
Inserts the given text into the text field identified by locator. Use keyword input password to insert a password in a text field.
Maximizes the SapGui window.
Opens a connection to the given connection name. Be sure to provide the full connection name, including the bracket part.
Runs a Sap transaction. An error is given when an unknown transaction is specified.
Scrolls the scrollbar of an element ‘element_id’ that is contained within a shell object. ‘Position’ is the number of rows to scroll.
Selects checkbox identified by locator. Does nothing if the checkbox is already selected.
Selects an item from the context menu by clicking a button or right-clicking in the node context menu.
Selects the specified option from the selection list.
select_node(tree_id, node_id, expand=False)¶
Selects a node of a TableTreeControl ‘tree_id’ which is contained within a shell object.
Use the Scripting tracker recorder to find the ‘node_id’ of the node. Expand can be set to True to expand the node. If the node cannot be expanded, no error is given.
Selects a link of a TableTreeControl ‘tree_id’ which is contained within a shell object.
Use the Scripting tracker recorder to find the ‘link_id1’ and ‘link_id2’ of the link to select.
Sets radio button to the specified value.
Selects an entire column of a GridView ‘table_id’ which is contained within a shell object.
Use the Scripting tracker recorder to find the ‘column_id’ of the column to select.
Selects an entire row of a table. This can either be a TableControl or a GridView ‘table_id’ which is contained within a shell object. The row is an index to select the row, starting from 0.
Sends a SAP virtual key combination to the window, not into an element. If you want to send a value to a text field, use input text instead.
To send a vkey, you can either use te VKey ID or the Key combination.
Sap Virtual Keys (on Windows) | VKey ID | Key combination | VKey ID | Key combination | VKey ID | Key combination | | 0 | Enter | 26 | Ctrl + F2 | 72 | Ctrl + A | | 1 | F1 | 27 | Ctrl + F3 | 73 | Ctrl + D | | 2 | F2 | 28 | Ctrl + F4 | 74 | Ctrl + N | | 3 | F3 | 29 | Ctrl + F5 | 75 | Ctrl + O | | 4 | F4 | 30 | Ctrl + F6 | 76 | Shift + Del | | 5 | F5 | 31 | Ctrl + F7 | 77 | Ctrl + Ins | | 6 | F6 | 32 | Ctrl + F8 | 78 | Shift + Ins | | 7 | F7 | 33 | Ctrl + F9 | 79 | Alt + Backspace | | 8 | F8 | 34 | Ctrl + F10 | 80 | Ctrl + Page Up | | 9 | F9 | 35 | Ctrl + F11 | 81 | Page Up | | 10 | F10 | 36 | Ctrl + F12 | 82 | Page Down | | 11 | F11 or Ctrl + S | 37 | Ctrl + Shift + F1 | 83 | Ctrl + Page Down | | 12 | F12 or ESC | 38 | Ctrl + Shift + F2 | 84 | Ctrl + G | | 14 | Shift + F2 | 39 | Ctrl + Shift + F3 | 85 | Ctrl + R | | 15 | Shift + F3 | 40 | Ctrl + Shift + F4 | 86 | Ctrl + P | | 16 | Shift + F4 | 41 | Ctrl + Shift + F5 | 87 | Ctrl + B | | 17 | Shift + F5 | 42 | Ctrl + Shift + F6 | 88 | Ctrl + K | | 18 | Shift + F6 | 43 | Ctrl + Shift + F7 | 89 | Ctrl + T | | 19 | Shift + F7 | 44 | Ctrl + Shift + F8 | 90 | Ctrl + Y | | 20 | Shift + F8 | 45 | Ctrl + Shift + F9 | 91 | Ctrl + X | | 21 | Shift + F9 | 46 | Ctrl + Shift + F10 | 92 | Ctrl + C | | 22 | Ctrl + Shift + 0 | 47 | Ctrl + Shift + F11 | 93 | Ctrl + V | | 23 | Shift + F11 | 48 | Ctrl + Shift + F12 | 94 | Shift + F10 | | 24 | Shift + F12 | 70 | Ctrl + E | 97 | Ctrl + # | | 25 | Ctrl + F1 | 71 | Ctrl + F | | |
Examples: | Keyword | Attributes | | | send_vkey | 8 | | | send_vkey | Ctrl + Shift + F1 | | | send_vkey | Ctrl + F7 | window=1 |
set_cell_value(table_id, row_num, col_id, text)¶
Sets the cell value for the specified cell of a GridView ‘table_id’ which is contained within a shell object.
Use the Scripting tracker recorder to find the ‘col_id’ of the cell to set.
Sets the delay time that is waited after each SapGui keyword.
The value can be given as a number that is considered to be seconds or as a human-readable string like 1 second or 700 ms.
This functionality is designed to be used for demonstration and debugging purposes. It is not advised to use this keyword to wait for an element to appear or function to finish.
Possible time formats:miliseconds | milliseconds, millisecond, millis, ms |seconds | seconds, second, secs, sec, s |minutes | minutes, minute, mins, min, m |
Example:Keyword | Attributes |Set explicit wait | 1 |Set explicit wait | 3 seconds |Set explicit wait | 500 ms |
Sets the focus to the given element.
Takes a screenshot, only if ‘screenshots on error’ has been enabled, either at import of with keyword enable screenshots on error.
This keyword uses Robots’ internal Screenshot library.
Removes selection of checkbox identified by locator. Does nothing if the checkbox is not selected.