SAPGuiSession Object
Description
Represents the SAP GUI for Windows session on which an operation is performed.
Operations
The sections below list the built-in methods and properties that you can use as operations for the SAPGuiSession object.
Note: You can also view a list and descriptions of the SAPGuiSession description properties, for use in object repository descriptions, programmatic descriptions, checkpoint and output value steps, and as argument values for the GetTOProperty and GetROProperty methods.
Methods
Check | Checks whether the actual value of an item matches the expected value. |
ChildObjects | Returns the collection of child objects contained within the object. |
GetAllROProperties | Returns the collection of properties and current values from the object in the application. |
Close | Closes the SAP GUI for Windows session without displaying a warning message. |
CreateSession | Creates a new SAP GUI for Windows session for the current connection. |
GetROProperty | Returns the current value of the description property from the object in the application. |
GetTOProperties | Returns the collection of properties and values used to identify the object. |
GetTOProperty | Returns the value of the specified description property from the test object description. |
Output | Retrieves the current value of an item and stores it in a specified location. |
Reset | Navigates to the session's initial screen or to the specified transaction. |
SetTOProperty | Sets the value of the specified description property in the test object description. |
Sync | Instructs UFT One to wait until the SAP GUI for Windows session is available. |
WaitProperty | Waits until the specified object property achieves the specified value or exceeds the specified timeout before continuing to the next step. |
Properties
Exist | Checks whether the object currently exists in the open application. |
Object | Accesses the native methods and properties of the object. |
Close Method
Description
Closes the SAP GUI for Windows session without displaying a warning message.
Syntax
object.Close
Return Type
None.
IMPORTANT
This method may be useful at the end of an action or test iteration to close sessions that were opened during the test run. This ensures that each iteration begins with the same number of open SAP Gui for Windows sessions.
Tip: You can close any open session that was launched by UFT One by checking the Session cleanup option in the SAP pane of the Options dialog box, or by checking the Close the session when the test is closed option in the Record and Run Settings dialog box. For more information, see the SAP Solutions Add-in in Add-ins section of the UFT One Help Center.
Note: This method is not recorded. To add this method to your test, use the Step Generator or enter it manually in the Keyword View or Editor. For more information, see the UFT One User Guide.
Example
'The following example uses the Close method to close an SAP GUI for Windows session without displaying a warning 'message. SAPGuiSession("Session").Close
CreateSession Method
Description
Creates a new SAP GUI for Windows session for the current connection.
Syntax
object.CreateSession
Return Type
None.
IMPORTANT
This method is recorded when you click the Create Session button in the SAP Gui for Windows toolbar.
Example
'The following example uses the CreateSession method to create a new SAP GUI for Windows session and then 'resizes the new window. Note that by creating a new session, a new session object (Session_2) is saved in the object 'repository. SAPGuiSession("Session").CreateSession SAPGuiSession("Session_2").SAPGuiWindow("SAP Easy Access").Resize 106, 24
Reset Method
Description
Navigates to the session's initial screen or to the specified transaction.
Syntax
object.Reset ([TransactionCode])
Arguments
Parameter | Description |
---|---|
TransactionCode |
Optional. A String value. The code representing the transaction to which you want to navigate. If no code is specified, the session's default code (the "/n" command code) is used Default value = "s000" |
Return Type
None.
IMPORTANT
In contrast to the SAPGuiOKCode.Set method, the Reset method can be performed at any point in your test.
Tip: We recommend using this method to ensure that tests are rerun from the initial screen of the session.
Note: This method is not recorded. To add this method to your test, use the Step Generator or enter it manually in the Keyword View or Editor. For more information, see the UFT One User Guide.
Example
'The following example uses the Reset method to reset the SAP GUI for Windows session to the initial session 'window. Then it resets the SAP GUI for Windows session to the VA01 transaction SAPGuiSession("Session").Reset SAPGuiSession("Session").Reset "/nVA01"
Sync Method
Description
Instructs UFT One to wait until the SAP GUI for Windows session is available.
Syntax
object.Sync ([TimeOut])
Arguments
Parameter | Description |
---|---|
TimeOut |
Optional. A long integer value. The timeout (in milliseconds) after which the test run continues regardless of the session status. Default value = 0 |
Return Type
None.
IMPORTANT
You can optionally specify a timeout after which the test run continues regardless of the session status.
This method can be useful when invoking a new session from an existing one or when moving from a session that is open on one server to a new session on a different server.
Notes:
If you do not specify a timeout value, UFT One uses the default Object Synchronization Timeout as specified in the Run pane of the Test Settings dialog box. For more information on the Object Synchronization Timeout, see the UFT One User Guide.
This method is not recorded. To add this method to your test, use the Step Generator or enter it manually in the Keyword View or Editor. For more information, see the UFT One User Guide.
Example
'The following example uses the Sync method to ensure that a second SAP GUI for Windows session (opened by pressing 'the "New message" button) is loaded before performing operations on it. (It does this after first having performed several 'operations on another SAP GUI for Windows session.) SAPGuiSession("Session").SAPGuiWindow("SAP Easy Access").SAPGuiOKCode("OKCode").Set "sbwp" SAPGuiSession("Session").SAPGuiWindow("SAP Easy Access").SendKey ENTER SAPGuiSession("Session").SAPGuiWindow("Business Workplace").SAPGuiButton("New message").Click SAPGuiSession("Session_2").Sync SAPGuiSession("Session_2").SAPGuiWindow("Create Document").SAPGuiEdit("Title").Set "A new message on a different " session "" SAPGuiSession("Session_2").SAPGuiWindow("Create Document").SAPGuiButton("Send... (Shift+F8)").Click
See also: