Nullable Elements

This tutorial uses a nullable element for an element that isn't always present on the page. The DOM Tree Viewer shows a login form. If you log in as an administrator, you see a profile card that includes a Setup button. If you're not an administrator, the profile card doesn't include the Setup button.

In the userProfile.utam.json page object, we declare the Setup button as "nullable": true.

    {
        "name": "setupButton",
        "nullable": true,
        "public": true,
        "selector": {
            "css": "button"
        }
    },

The test logs in as an administrator and validates that the profile element includes a Setup button.

Then, the test logs in as a regular user (not an administrator) and validates that the profile element doesn't include a Setup button. When the button is absent, the setupButton element is null.

If we remove "nullable": true from the setupButton element in userProfile.utam.json, the test will log an error when it tries to find the Setup button for the regular user. If you don't believe it, try it yourself!