Skip to content

Merge the values from dataset into the variables within the Email body

This example demonstrates how to implement compose and distribution of an email from within the context of an automated test in execution.

Worksoft SaaS is agnostic to the purpose these emails serve in the context of your business, be it a notification of a positive outcome or a negative outcome.

In this example, first the sender is set, then the subject, recipient list (to, cc, bcc), followed by the email body, and finally, the email is distributed. For email body, a simple text string is used. In real life, the email body usually is not that simple where static text satisfies your needs. Please refer to other examples that cover techniques that will help you build email bodies incrementally, including multi-part mime types (embedding screenshots, attaching files, etc).

Solution:

# Command Target Value
To begin the email service block
1 emailBlockStart    
To set the sender for the composed email
2 setSender noreply@worksoft.com  
To set the subject for the composed  email
3 setSubject Worksoft SaaS Notification: Issue identified  
To set the ‘To’ recipient list for the composed email
4 setRecipientToList justin@gmail.com  
To set the ‘CC’ recipient list for the composed email
5 setRecipientCCList joe@gmail.com,meera@gmail.com  
To set the ‘BCC’ recipient list for the composed email
6 setRecipientBCCList amar@gmail.com  
To create the email body with a variable name
7 createBody body_template  
To create an email body part from Text or HTML string
8 createBodyPartFromTextOrHTML Hi All,
Please note that Worksoft SaaS has completed executing the test and captured below errors
Runid: ${column name1}
web url: ${column name2}
short failure description: ${column name3}
body_template
To append the body part into the email body
9 appendBodyPartToBody body_part1 body_template
To merge the required values into body part variables
10 mergeValuesIntoBodyPartVariables body_template Product Details
To send the composed email to the sender’s specified in “To, CC and BCC” list
11 sendEmail    
It indicates the end of the email block
12 emailBlockEnd    

Tips, Tricks, Gotchas & Best Practices:  

  • The subject can be foreign language characters.
  • You can also use CSS styles like underlines, font color, and to highlight anything important in bold letters and the table background color in the email body to make the email look effective.

Representative Usage Scenarios for this Example:

Use Case #1:

After scheduling a run/batch of runs in Worksoft SaaS, the user has to login to Worksoft SaaS to know the run details, inputs and the screenshots of each and every test run as part of certification/CTC runs. The user can log in and search for the respective run details if the runs are in a single number.
What would be the case if there were hundreds of runs?

Consider a driver run, in order to trigger the batch of test runs at the scheduled time, we prefer using driver run which in turn triggers the actual runs.

If the user wants to know the run details in the driver runs like Run Definition Name, Run ID, Testing Context Key, Test Start time, failure reason, the instance of failure occurrence and the response of the scheduled run...and so on. Then the user has to check those scheduled runs in Home screen else, checks the count through the Test Cycles screen by searching the Test Cycle Identifier under which runs are grouped. This process involves multiple navigations, ambiguity and time consumption. 

Also in case of failures, while triggering the runs, the triage to identify the root cause for failure would consume a lot of time if more runs are executed.

To enable the user to have access to the information faster w/ minimal actions; Worksoft SaaS allows to customize emails which can be triggered by the execution.

The Email notification with the feature of merging the values from the dataset into variables would really help the user to identify the results easily instead of logging into the Worksoft SaaS application. This email can be customized in such a way that the values in the dataset/datasets will be pushed into the variables within the email body which helps in providing the relevant information in the email. The values of the respective column names in the specified dataset will be pushed to the email body wherever that column names were called let us say, ${column name}. 
Consider a dataset name Product Details with column names as column name1, column name2 and column name3. If the user wants to push these details into the email body the user uses ${column name1/column name2/column name3}(as per the requirement). Here the column names were pushed into the run id, web URL, and short failure description respectively and the representation of this within the commands is mentioned in the Sample Script. Similarly, we can also merge the values from dataset2 as well as using the same command for twice but with different datasets in the value field.

An email can be customized using the above commands in such a way that the below details will be sent to the user within the email.

  1. Run Definition Name
  2. Run ID
  3. Testing Context Key 
  4. Test Start time 
  5. Response of the scheduled run 
  6. Input driver Data File 
  7. Input file 
  8. Output Data Set 
  9. Error message

Use Case #2:

Consider an e-commerce site https://www.amazon.com, add 5 or more products into the cart, verify the count of products in the shopping bag, proceed to checkout, add shipping details and complete payment method and then try to place an order.

In the above process, there are certain cases like

1. Products may or may not add into the cart 
2. Product may available or may not available or out of stock 
3. The payment process may successful or unable to process the payment details 
4. The Order may be placed or may not be placed 

If the user wants to capture all the above - mentioned cases w/ relevant details like product name, order number, payment details, etc.., an email can be customized using these commands and sent to the user using the email commands.

Feedback and Knowledge Base