Capture an Application using SAP Build Process Automation
- How to capture an application with different screens
- How to declare elements of a captured application
- How to build an automation using a captured application
Prerequisites
- A regular account with SAP BTP Free Tier service plan for SAP Build Process Automation
- Install and Setup the Desktop Agent
In this tutorial, a Sales Orders web application is captured and details will be retrieved for a specific sales order through an automation.
- Step 1
-
Open the following link in a new browser window: Sales Order Application.
-
In Artifacts create a new Application.
-
Select Browse Order application that was is opened in step 1.1.
-
On the Screen Details panel on the right:
- Select Capture Application.
- Select Create a new application.
- Set the Application Name to Order Management.
- Set the Screen Name to Orders List (or Main List).
- Click Capture.
-
Go back to the application browser window and click on first order to get the second screen.
-
In the Order Management Application, create a new Screen.
-
On the Screen Details panel on the right of the window that popped-up:
- Select Browse Orders screen.
- Set Screen name to Order Details.
- Click Capture.
On the right side, there is a warning message “Another screen matches the criteria beforehand”, putting the right criteria will fix it.
-
Click on Order Details then click on the Title Criteria.
-
In Modify Criterion small window:
- Set Property to URL.
- Set Operator to contains.
- Set Value to
?tab=
. - Click Apply.
-
Repeat the steps 1.8 and 1.9 for Orders List Screen while setting Operator to doesn’t contain.
The application is now created with its two screens.
Log in to complete tutorial -
- Step 2
In Order Management Application, click on Orders List Screen.
Select Both option situated in the top to show the DOM Tree, then click on first order on the screen.
In Element Details on the right:
- Set Name to Orders.
- Remove Text recognition criteria.
- Click Declare Element.
In Declared Elements on the left, select Orders element and set it as Is a collection using the button
.Find the element Order Date using the DOM Tree.
Order Date element:
- Set Name to Order Date.
- Remove Text criterion.
- Select Class criterion on Captured Data panel.
- Click Declare Element to declare this element.
Set Order Date as Is a collection as shown in step 2.4.
Repeat same steps ( 2.5 ~ 2.7 ) for Order Status.
Repeat same steps ( 2.5 ~ 2.7 ) for Order Number.
Select Save. Orders List screen’s three elements are now declared.
Log in to complete tutorial - Step 3
In Order Management Application, click on Order Details Screen.
To declare Order Price.
- Click on 410,418.22.
- Set Name to Order Price.
- Remove Text criterion.
- Select id criterion on Captured Data panel.
- Click Declare Element to declare this element.
Repeat step 3.2 for Order Number element.
Repeat step 3.2 for Shipping Address’s 5 elements:
Element Name id (Criterion) Name Address Name __text37
Street Address Street __text38
ZIP Code/City Address zip city __text39
Region Address Region __text40
Country Address Country __text41
Repeat step 3.2 for Customer element.
Select Save to save your changes. Order Details screen’s seven elements are now declared.
- Step 4
Create a new Data Type.
Data Types are used to describe an entity’s schema. An example of that would be describing a person using his: First name, Second name, Age, etc…
Set Name to Sales Order.
Now, declare its fields. Click New Field to create a new field in Data Type.
Add the following fields:
Field Name Type orderNumber
String orderDate
Date orderAmount
Number shippingCountry
String orderStatus
String You will notice that not all declared elements were used.
Select Save to save your changes. Sales Order datatype is now ready to be used.
Log in to complete tutorial - Step 5
Create a new Automation artifact and name it Get Order Details From Application.
Order Number has to be passed as an input to our automation and return a Sales Order as an output. Click on the canvas of the automation then click Input/Output.
Click Add new input parameter.
Set Name to
orderNumber
(Case sensitive) and Type to String.Click Add new output parameter.
Set Name to
order
and Type to Sales Order.
Log in to complete tutorial - Step 6
Add Order List Screen to the automation.
Select on the screen in the automation then click Define Screen Activities.
Search Start Web Page activity and drag-and-drop it inside the Orders List screen.
Click on Start Web Page activity to modify its attributes:
- Make sure the target is set to
Orders Management > Orders List
. - Select your browser.
Note: SAP Build Process Automation browser extension must be installed on the used navigator.
To find the desired order’s details, iterating through the orders is mandatory.- Make sure the target is set to
Search For Each activity, and add it inside the screen activity in the automation.
Choose For Each activity, then:
- Click Target Editor.
- Select Order Management > Orders List > Order Number.
- Click Confirm.
Select on the screen to open Define Screen Activities, then:
- Search for Get Element screen activity.
- Drag-and-Drop it inside of the For Each activity in the automation.
- Open Target Editor.
- Select Order Management > Orders List > Order Number.
- Set Index of the element to (2) index.
- Set Output Parameters to
currentOrderNumber
.
To check whether the order in the current iteration of the for loop matches the one we have in the input, checking equality must be done. Search for Condition activity:
- Drag-and-Drop it inside the For Each Activity,
- Click on it to edit its attributes,
- Open Edit Formula,
- Set expression to
Step0.orderNumber === Step3.currentOrderNumber
, - Click Save Expression.
When the order is found, its details are retrieved.Add four Get Element screen activities inside of the condition activity.
For all Get Element screen activities:
Get Element n° Name Target Output Parameters First Get Order Status Order Management > Orders List > Order Status (with Index of the element set to (2) index) orderStatus
Second Get Order Date Order Management > Orders List > Order Date** (with Index of the element set to (2) index) orderDate
Third Get Order Price** Order Management > Orders Details > Order Price orderPrice
Fourth Get Order Country Order Management > Orders Details > Order Country** orderCountry
You can notice that Order Details screen was added when its elements were used by Get Element screen activity. That is because in order to use an element it has to be wrapped by its screen.
To access the second screen, we must click on the adequate order:
- Add a Click screen activity before Order Details screen activities.
- Set its target to Order Management > Orders List > Orders with Index of the element set to (2) index.
- Add a Wait activity right after Click screen activity.
To store the gathered data, create a Sales Order variable. Search for Sales Order on the right panel.
Drag-and-Drop it at the top of the automation, right after Start.
Click on the activity and set Output Parameters to
order
.At the end of the automation, click End and set order to
order
.Add Set Variable Value activity after Order Details screen:
- Set variable attribute to (1) order.
- For value field select Create Custom Data.
- For the 5 fields that appeared:
Field Name Value orderNumber
(4) currentOrderNumber
orderDate
(7) orderDate
orderAmount
Open expression Editor and set value Number.parseFloat(Step10.orderPrice)
shippingCountry
(11) orderCountry
orderStatus
(12)
Add Loop End control after Set Variable Value activity to stop the looping process once the order is found and its data is retrieved.
To show the resultant order after the execution finishes, add Log Message activity and set Value to
(1) order
.Choose Save to save your changes.
The automation is now finished and ready to be used as a standalone automation or with a process. The final automation looks as below:
Log in to complete tutorial - Step 7
-
Choose Test.
-
Set
orderNumber
to an existing order in the website (ex. 7991) to test the automation with it. -
Test Results:
- Automation opens Chrome Browse Orders Application.
- Loops through all orders and verifies whether the order with the order number given in the input exists. If it finds the order it clicks on it and sets the values present in the screen.
- Ends the looping.
- The Order is retrieved and shown with all its details in Test Console.
Log in to complete tutorial -