MaestroThe UI design product. | Form Builder | All versions This feature is related to all versions.
Occasionally, while developing Maestro forms, you may see a behavior that doesn't seem right and you can't figure out why. This usually occurs in relation to rules that you've created using the script editor. It's very important to understand the form architecture before you delve into form debugging, as there are certain assumptions of how the 3 form elements are used in interact within the form.
You can learn how to do the basic debugging of Maestro forms, but sometimes you need to apply more advanced debugging techniques that you can use to find out what is going on in your script and in the form data, especially debugging CSS and styling issues are not covered.
Debugging Maestro forms in the browser is a technical task and requires some understanding of web application development in general, specifically the web standards of HTML, CSS and JavaScript.
Additionally, forms produced by Maestro run on AngularJS, which is a JavaScript based open-source front-end web application framework backed by Google. There is a very strong community supporting this technology and while it is not required that you are familiar with AngularJS, it would be a benefit for you to have some basic knowledge of the framework. We would recommend you review the tutorials to develop your understanding of this technology:
Before getting started, ensure you have appropriate tools for debugging JavaScript in the browser. These include:
Most modern browsers come with good developer tools these days. We prefer to use Google Chrome, but Firefox and Microsoft Edge can also be used. This article assumes you are using Google Chrome, which we recommend.
All these browsers come with developer tools out of the box and allow you to install plug-ins and extensions to provide additional capabilities. There are a number of ways to enable these developer tools, but universally, hitting the F12 key while viewing a page will bring up the built-in developer tools.
After that, you can run various commands in the console to print form's data. For example, you can use console.log(maestro.Form.getDataXml(true)) to list the /SFMData/SystemProfile content as an XML file, as shown below:
<AvokaSmartForm>
<AboutYou>
<FirstName>
</FirstName>
</AboutYou>
<SFMData>
<SystemProfile>
<FormCode>Test 1</FormCode>
<RequestLogKey>12345</RequestLogKey>
<DisplayMode>Entry</DisplayMode>
<ServerBuildNumber>22.4.0</ServerBuildNumber>
<RevisionNumber>0</RevisionNumber>
<FormDataServiceURL>https:/[/YOUR-SERVER-HOST-NAME]/web-plugin/servlet/FormDynamicDataServlet</FormDataServiceURL>
<TrackingCode>ABCD1234</TrackingCode>
<AbandonmentReason>
</AbandonmentReason>
<AbandonmentComments>
</AbandonmentComments>
</SystemProfile>
</SFMData>
</AvokaSmartForm>
Maestro forms are built on the AngularJS framework and plugins are available to provide specific support for AngularJS web applications. In Chrome, we use AngularJS Batarang, Firefox also has AngularJS plugins that may provide the same capability.
When you publish a Maestro form there are a number of options available to you.
Some of these are very relevant to debugging, these are:
| Publish Options | Description |
|---|---|
| Minify Code |
Deselect this option. Code minification is the process of compressing code to reduce the size and therefore load time, but does not affect the operation of the code. The process removes unnecessary characters from the code,white space, new line, comments etc... The result of minification is a single line of code that is very long and difficult to read and debug so ensure that this option is deselected for debugging. |
| Remove Automation Framework |
Deselect this option. The automation framework built into Maestro forms facilitates UI driven automated tests such as those that would be run from test tools like Selenium. This framework also contains some features that will assist in debugging JavaScript so it is handy to keep the automation framework for debugging. |
To start a debugging session you should:
While debugging forms you may need to republish your form with changes multiple times and you need to refresh the page with your published form on it each time. The following keyboard shortcuts are available for you to use to streamline this process:
Refreshing the page with the republished form on it should leave the browser developer tools active so you should not need to reactivate them each time.
In the Maestro framework, the Form object contains everything else you might need to access for debugging including the View, Items and Data (see Maestro Form Architecture), so to access any of these elements you need to scope the Form object. There are a number of ways to do this from the Console tab in the browser developer tools:
$("Form").scope().Formmaestro.Form$scope.FormEnter one of these directives into the Command prompt in the Console tab and press Enter to scope the Form object:
Opening up this object you will see a long list of sub elements but among those you will find the 3 key elements to the Maestro Form Architecture, the Form Data object,
The Form Items,
And the Form View.
Of course, if you have a JavaScript debugging session active (as described below) you will have access to the Form Data object in the function scope and can readily inspect its contents.
There is a handy Util function to generate a printable representation of an item and log it to the console as follows:
$scope.Util.logItem($scope.Form.items.personalDetailsBlock)
"personalDetailsBlock
┌ firstName
└ middleNames
─ lastName
─ dateOfBirth
┌ day
│ month
└ year
─ date
─ daysData
─ emailAddress
─ mobileNumber
"
All rules in Maestro are implemented as JavaScript so to locate the logic implemented in a Maestro rule you must find the JavaScript code that implements that rule. You can do this as follows:
A word of caution against modifying JavaScript in-line in the browser debug tools. Results of this sort of change are often unreliable. While it is less convenient to republish a form each time you want to change a rule - this is the recommended approach.
Next, learn about UI test automation.