The following example illustrates how Studio can be used for creating a workflow to automate the login to SAP.
The workflow is comprised of three sequences that perform authentication into the SAP server, check for exceptions, bypass the welcome message, and close the SAP window, so that it may cover most possible scenarios that you could come across when wanting to log in to SAP.
SAPLoginMain.xaml invokes a workflow for closing any running SAP instances, using a Do While activity that checks for any open SAP windows and attempts to close them three times, using an If activity. The If also contains a Throw activity for generating an exception if the workflow is unable to close the SAP windows.
Once all SAP windows are closed, the
SAPLoginMain.xaml comes into play. The Try Catch activity invokes the
SAPLoginDoLogin.xaml workflow, which logs into SAP using the credentials and parameters passed as arguments.
The Attach Window activity inside the
SAPLoginDoLogin.xaml workflow inserts arguments like client and language, which are optional, together with the username and password. After the credentials are entered, the Send Hotkey activity presses Enter so that the
SAPLoginMain.xaml can check for a welcome message and bypass it with a Click activity.
The workflow then checks if the user is logged in, and then verifies if the copyright popup appears so that it may bypass it using a Click activity. The last sequence in the workflow uses an Element Exists activity to check if the SAP main screen exists, and an If activity to log a message if the login was successful or throw an exception if it failed.