This article walks through the various command and validation steps for the Uptime.com Transaction check. It assumes you are creating your first check, or are adding/testing new steps for an existing check.
For setup instructions, see this article. For tips to improve your Transaction check, see this article.
Table of Contents
- Authentication and Settings
- Commands
- TOTP MFA
- Go To URL
- Click Element
- Hover Element
- Focus Element
- Fill in Element with Text
- Check/Uncheck Checkbox/Radio Button
- Submit Form Element
- Wait for Element to Exist/Not Exist
- Wait for Element to Contain Text/Not Contain Text
- Wait for 1 Second
- Set Variable
- HTTP Status Code Should Be Status
- URL Should/Should Not Contain
- Title Should/Should Not Contain
- Element Should/Should Not Exist
- Element Should/Should Not Contain Text
- Checkbox/Radio Button Should/Should Not Be Checked
- HTTP Header Should/Should Not Contain Text
Commands
Authentication & Settings
Sets HTTP basic auth and other settings including HTTP Headers, Browser Viewport Size, whether to run the check as Mobile, and TOTP MFA commands. This step always defaults to step 1 when it is utilized. The parameters in this command are below:
Auth and Settings Commands
Basic Auth: Allows you to provide credentials for pages behind Basic HTTP Authentication. You will need a username and password. We highly recommend that you create unprivileged test credentials for any checks that utilize HTTP basic auth.
HTTP Headers: Defines HTTP Headers to be sent with a request. User-Agent is disabled. HTTP Headers must be separated by line break in the Name: value format.
Screen Size: Defines the viewport size the check will run, or the device the check emulates. The default is 1366x768.
Filter URLs: List of domains/URLs to block when executing a check. Regular expressions are supported. One per line. You can verify your designated URLs have been blocked from the Transaction check in your Browser Console.
Note on Browser Console Log: Transaction checks that are run on a page which also contains a RUM collector script will not record events generated by Uptime.com checks. When running a transaction check on a page that also includes a RUM collector script, you may see the following message:
Response 406 received for https://www.rumcollector.uptime.com
Failed to load resource: the server responded with a status of 406 ()
This does not indicate an error in the transaction check; it simply means that the RUM collector script is incompatible with the transaction check.
Mobile: Adds a Mobile flag into the request User-Agent string. When this option is used, the browser also takes into account a page’s `meta viewport` tag and provides touch events support.
TOTP Secret: Secret key for generating TOTP codes for two-factor authentication. OTP code is available via $TOTP_TOKEN$ variable. Individual OTP digits are available via $TOTP_TOKEN_1$, $TOTP_TOKEN_2$ etc.
TOTP Period: Period for generating TOTP codes. Defaults to 30 seconds. This value is used to calculate the TOTP code validity period. Only change this when your TOTP provider uses a different period.
TOTP Digits: Number of digits for generating TOTP codes. Defaults to 6 digits.
TOTP MFA
For the commands below, you will need to set up 2FA authentication against the target website. The following parameters, which are usually hidden, will need to be obtained and configured within the Authentication & Settings step:
- Secret Key
- Period (default 30 seconds)
- Number of digits (default 6)
Test Case Scenario
We will show how to utilize the parameters above when using the Transaction check recorder, with a newly created Uptime.com account with 2FA enabled.
- First, on the transaction recorder, you will need to add the Authentication & Settings Step above the Go To URL step.
- Next, start the recording, and enter in the Uptime.com credentials until you reach the setup key screen on the recorder.
- On the Authentication & Settings step, add the Setup Key to the TOTP Secret value box.
- Once added, you will need to press the Get Code button, which will prompt a pop up dialog box. to enter the 2FA token value.
- Select the Submit button, and you will be now logged into Uptime.com
With the 2FA account setup successfully within the transaction check, you will now need to replace the OTP code from the script.
In order to fill in the OTP code, replace the code from the Fill in step with a variable such as $TOTP_TOKEN$
TOTP can be also saved and used in the Vault if desired. More information can be found here.
Go To URL
Navigates the browser to the URL that you specify. Note that the target page must load within 30 seconds otherwise the transaction will fail with a page load timeout. Navigation is considered finished when the load event is fired.
Use Wait Until to specify the event that will trigger successful navigation. The following options are possible:
- Wait until the Load event is fired - This is the default setting for the Transaction check, and moves to the next step only after the page is fully loaded. More info about the load event is available from Mozilla.
- Wait until DOMContentLoaded event is Fired - This setting moves to the next step after the page’s HTML has been completely loaded and parsed. It does not wait for stylesheets, images, and subframes. More info about the DOMContentLoaded event is available from Mozilla.
- Wait until there are no more than 0 network connections for at least 500 ms - This setting waits for every request to complete, and will advance to the next step only after all network connections have been closed for at least 500 ms.
- Wait until there are no more than 2 network connections for at least 500 ms - This setting waits until there are only 2 or fewer requests left to complete, and will advance to the next step only after all but 2 or fewer network connections have been closed for at least 500 ms.
You can specify Timeout for the Go To URL step as well. To force the check to move onto the next step after the Go To URL step completes, tick the box labeled Do not wait for navigation.
Note: Uptime.com adds 1.2 seconds upon navigation by default to allow for javascript and important assets to load.
Click Element
Clicks on the specified HTML element. Use the id, name or CSS selector of the element you wish to interact with. Users can define Left, Middle, or Right mouse click, with options to Single, Double, or Triple click.
The click command simulates a mouse click of your chosen button and then waits 1.2 seconds for navigation that may occur after the element is clicked. To force the check to move onto the next step after the Go To URL step completes, tick the box labelled, Do not wait for navigation.
Hover Element
Performs a mouse hover over the specified element. Use this command for elements that utilize the :hover selector.
Focus Element
Focuses on the specified HTML Element. Use this Command for elements that utilize the :focus selector.
Fill in Element with Text
Fill in a form's text, password, hidden, select, or textarea field with the given text or value. It is also possible to specify a Typing Delay (in milliseconds), that will delay each keystroke when emulating typing into an editable field.
Check/Uncheck Checkbox/Radio Button
Checks or does not check a specified checkbox or radio button. Use the id, name or CSS selector of the element you wish to interact with.
Submit Form Element
Submit the specified form (can also be done by button click)
Wait for Element To Exist/Not Exist
Waits until the specified HTML element exists, or does not exist, on the page. Use the id, name or CSS selector of the element you are waiting for.
There is an option to set the timeout up to 900 seconds.
Wait for Element To Contain Text/Not Contain Text
Waits until the specified HTML element appears, or does not appear, and then waits for the element to contain or not contain the given text. Use the id, name or CSS selector to specify the element, then define the text it should contain, or does not contain. Users can tick a box to enable regex matching as needed.
There also an option to set the timeout up to 900 seconds.
Wait for 1 Second
Pauses for 1 second and then continues to the next step. Use this as a last resort if you need the browser to wait for some javascript to run. Usually using one of the “Wait for Element” steps is much more reliable.
Set Variable
Set a variable that can be used in subsequent steps. To use this variable in other steps as either an input or validation value, enclose the variable name in dollar signs ($). For example, you can use a variable such as CLIENT_NAME in a validation step text parameter as “Welcome, $CLIENT_NAME$”. The variable value can consist of alphanumeric characters, as well as an underscore. Variable names are case insensitive.
The value of the "Options" field is treated differently depending on its variable type. Below are explanations per each type:
Element Text
Options: Element Name, ID, CSS Selector or XPath
The variable value is set from the contents of the element you’ve referenced; for example, the user’s name from a Dashboard.
Current Date & Time
Options: Format string, eg MMMDDYYYYh:mmaz (Please utilize this link for all format specifiers)
The variable’s value is the current date and/or time in UTC. Use the specified format as cited/linked above.
Using Adjustment in Seconds, it is possible to add X number of seconds to the current time. For example: a value called “PRESENT” with the Format expressed as MMDDYYYYh:mm:ss with an Adjustment in Seconds of 15 will hold the current time (month, day, year, hour, minute, seconds) and add 15 seconds. To add one minute, fill in Adjustment in Seconds with 60. To add one day, fill in Adjustment in Seconds with 86400, etc. Negative integer values are also possible.
Attribute Value
Define a variable derived from an attribute of an HTML element. The Element Selector is used to define the element name, id, CSS selector or XPath that holds the value you want to recall. The Attribute Name defines the specific element attribute to take the value from.
The variable’s value is set from the matching element attribute. This variable is most useful when you need to extract data from an element, where the element will not change but some attribute might.
Some examples include:
- Searching for the ID of an image
- Recalling a detail hidden from a list of items (such as which item is in an “active” state)
- Recalling a detail hidden from the end user (such as last synced date)
Random Value
Define a range of numbers and/or characters to be chosen from a comma separated list. Using a random value as a variable can be applied to text fields, forms, and even the URL.
Examples of this include:
- [Number-]Number, e.g. 100 or 1705-1980 - Random integer number in specified range, or from 0 to specified number.
- [Number:]List, e.g. 3:1, a, b, c, 37 - Random string composed from Number (default 1) elements of List. The result from the example could be: 1b37.
Constant
Options: string
Variable Verification with Browser Console
You can verify the values for Set Variable are set and called properly at each step from the Browser Console, by clicking “View Console” from the Run Test screen, or clicking “Root Cause Analysis” in an Alert notification.
Validations
HTTP Status Code Should Be Status
Checks that the HTTP status code matches the specified status (eg. 200 or 404). You must enter a numeric HTTP status code.
URL Should/Should Not Contain
Checks that the browser’s URL does or does not contain the given text or regex option (if enabled). Users can tick a box to enable regex as needed. Please note: regular expressions can also contain variables.
Title Should/Should Not Contain Text
Checks that the page title attribute does or does not contain the given text or regex option (if enabled). Users can tick a box to enable regex as needed. Please note: regular expressions can also contain variables.
Element Should/Should Not Exist
Checks that the specified HTML element does or does not exist on the page. Use the id, name or CSS selector of the element that should exist.
Element Should/Should Not Contain Text
Checks that the specified HTML element does or does not contain the given text or regex option (if enabled). Use the id, name, or CSS selector of the element, then define that text that it should contain. Users can tick a box to enable regex as needed. Please note: regular expressions can also contain variables.
Checkbox/Radio Button Should/Should Not Be Checked
Verify that the specified checkbox/radio button is or is not checked. Use the id, name or CSS selector of the element you wish to interact with.
HTTP Header Should/Should Not Contain Text
Verify that the specified HTTP Header contains or does not contain text. This validation step checks that the value following the colon (:) contains the text as intended. Using this validation step, you can validate any HTTP header including "Content-Type".
Comments
0 comments