Simple decision making: do not execute

Internet Explorer and Firefox

You can use this code sample to handle simple decision making in Internet Explorer and Firefox (this code does not work in Chrome). Put the code in a Custom action using the control window as the target. The first two lines create a locator pointing to the browser window. The IF statement checks to see if the page contains the word MASTERCARD. If it does not (then -1 is returned), then actions 3 and 4 are skipped. Otherwise, if the text is found, then actions 1 and 2 are skipped.

JavaScript uses zero-based indexes here, so steps[3] refers to the 4th step of the script, and actions[1] refers to the second action in the step.

var loc = new Locator();
var win = loc.findFrame('gomez_top[0]');
if (win.document.body.innerHTML.indexOf('CREDIT CARD') == -1) {
script.steps[3].actions[3].type ='do_not_execute';
script.steps[3].actions[4].type ='do_not_execute';
} else {
script.steps[3].actions[1].type ='do_not_execute';
script.steps[3].actions[2].type ='do_not_execute';


This code sample is how we handle simple decision making in Chrome. The code will also work Internet Explorer and Firefox, the difference from the code sample above being that Chrome requires two different Custom actions to handle decision making.

The first Custom action should use gomez_top[0] as the target window.

You can see we are again searching the page using the indexOf() function to determine if certain text exists on the page.

if (document.body.innerHTML.indexOf('stuff to search for') != -1) {
	gomez_control.setVar('doNotExecute', 'true');
		} else {
			gomez_control.setVar('doNotExecute', 'false');

A second Custom action, using the control target window, is needed to actually set which actions of the scripts will not be run (do not execute).

alert (doNotExecute);
if (doNotExecute == "true")

Dynatrace University has a training module to demonstrate this method: WATCH VIDEO.