Tricentis Test Automation for ServiceNow Recap 1

Today we are happy to launch the first edition of Tricentis Test Automation for ServiceNow Recap - the Tricentis Test Automation for ServiceNow Teams Development blog - where we talk about Tricentis Test Automation for ServiceNow features, automated testing and more. We hope this will help keep everyone informed about the platform and help you with your automation journey.

Summary

  • Orlando Beta functionality released.

  • New Jump To feature allows you to navigate between recent records and common tables from anywhere within the Tricentis Test Automation for ServiceNow application.

  • Versioning.

Upcoming Release

Orlando Support

We will have two releases:

  • 2.16.4 - which addressed some defects in the ServiceNow Framework.

  • 2.17.0 - which introduced Orlando Beta support.

Since Orlando is still under development at the time of writing, this will likely get a few more updates prior to the release. We will include any known issues we see in the Release Notes.

Jump To

As long as we have been using ServiceNow, the navigation has always been a struggle. Trying to navigate up and down related records is time-consuming and often puts you in the wrong place. In 2.17.0 we released a new feature named Jump To feature to simplify this navigation. It allows you to navigate quickly between Tricentis Test Automation for ServiceNow records from the context menu.

Just right click on the form header, and at the bottom will be a new Tricentis Test Automation for ServiceNow menu. It will show some of the most recent items and at the bottom, quick links to navigate to the Plan and Latest Run.


Spotlight Feature

Test Case Versioning

Versioning is a new feature in Tricentis Test Automation for ServiceNow 2.16.0 that adds the ability to have multiple concurrent test cases that can be executed in different environments. This means that while code is being developed - before it is integrated with production - a different test case can be used to validate functionality.

Questions of the Week

How Can I Run a Test in Headless Mode?

Chrome has recently release functionality to run Chrome completely in headless mode. This is a special mode for automation which allows the browser to run without actually showing the user interface. It is useful in cases where the Tricentis Test Automation for ServiceNow Service is running as a Windows Service without an interactive session.

To enable headless mode go to your test’s Configuration and add a new Option. Set the following field values:

  • Option to headless

  • Value to true

Your tests should now run without the interface but everything else should stay the same, even the ability to take screenshots.

How Do I Validate a Derived Field on a Form?

In ServiceNow it is common to show derived fields - which are fields included on a form which belong to the table of a referenced field. For example pulling in the email of a user on the Incident form. Testing these fields uses the same commands for fields (getFieldValue, getFieldDisplayValue, setFieldValue) but you need to include the reference field as a prefix.

client.getFieldValue('caller_id.email').should.contain('@email.com');

How Can I Get the Count of Grouped Records in a List?

This was a great question that came in this week asking how to find all groups in a grouped list with a total over a certain amount. It took me a while to solve and while it may not make it into the framework as a command, I think the code and the techniques would be helpful to cover.

On a form, when you group by a field, it will redraw the list with expandable sections for each unique value in the grouped field. The code behind the sections does not store the count in a distinct element so it is necessary to parse the count out from the label.

// Get all the list groups by finding elements with the list_group class
// client.elements is a low level WebDriver command and it returns
// an object with many technical properties.
// The actual elements are stored in the value property
let listGroups = client.elements('//span[contains(@class,"list_group")]').value;

// Next I iterate over all the list groups using map which will transform the array
// using a given function
// Within the iterator function I look up the text value of the elements which is the
// label of the row
// The map function is part of the lodash library 
// (although JavaScript now supports map as part of the core Array methods)
let listGroupLabels = _.map(listGroups, function(group) {
  return client.elementIdText(group.ELEMENT).value;
});

// Again using a lodash function filter, I look through each label and find the numeric
// portion, then check to see that count is over the target amount, if so I return true
// and that label is returned
let listGroupCounts = _.filter(listGroupLabels, function(groupLabel) {
  let count = parseInt(groupLabel.match(/\((\d*)\)/)[1], 10);
  if (count > 10) {
    return true;
  }
});

// Finally I remove the counts from each row entirely
// This part wasnt strictly necessary but makes the validations easier since you can do
// an exact assertion rather than a contains
let listGroupLabelsOnly = _.map(listGroupLabels, function(groupLabel) {
  return groupLabel.replace(/\(\d*\)/, '').trim();
});

// Finally I can do the assertion
listGroupLabelsOnly.should.contain('Priority: 1 - Critical')

Here is a shorter version that uses a reduce function instead of a separate map and filter functions.

// Get all the list groups
let listGroups = client.elements('//span[contains(@class,"list_group")]').value;

// Reduce array down to only group labels which contain more than 1 item
let listGroupLabels = _.reduce(listGroups, function(result, group, key) {
  	let groupLabel = client.elementIdText(group.ELEMENT).value;
    let count = parseInt(groupLabel.match(/\((\d*)\)/)[1], 10);
	if(count > 1){
      result.push(groupLabel.replace(/\(\d*\)/, '').trim())
    }
  	
  	return result;
},[]);

// Check list contains given value
listGroupLabels.should.contain('Priority: 2 - High')

Final Comments

Lately, we have seen many questions come in through the Helpdesk system and really they are great. It helps us improve the product when you ask questions, so if you feel like you are struggling or have an idea for a product feature please don’t hesitate to open a ticket.