Recorded Login File Format
You don’t need this page for most Recorded Login setups. Use it when you need to edit a recording by hand, for example to change a password, to fix a selector after your site changed, or to remove login steps from a Recorded Crawling file.
Structure
A Recorded Login file is a JSON document with two arrays of actions. An action tells the scanner how to interact with the site, such as moving the mouse, clicking an element or typing into an input field.
| Array | When it runs |
|---|---|
Commands | Once, at the start, to reach the logged-in state. If an action fails, or an assertion in it fails, the chain stops and the recording counts as failed |
SanityChecks | After all Commands have succeeded, and then once per minute for the rest of the scan, to confirm the scanner is still logged in. If a check fails, all Commands run again to log back in |
Cookies set while the actions run are used later during crawling and security testing.
Actions
Each action has these fields:
| Field | Meaning |
|---|---|
type | The kind of action, such as UserAction, Selenium, Helper or Extractor |
version | The action’s version |
command | What to do, such as open, input, mouseClick, sleep, verifyElementPresent or verifyURL |
selectors | How to find the element the command acts on |
values | The command’s input, such as a URL to open or text to type |
Selectors
A selector starts with the kind of locator it uses:
css=input#searchInput
xpath=/html/body/div[2]/div[1]/div[1]/div[2]/form/div[2]/div/input
text=LoginMatching Text
Commands that check text, such as verifyURL and verifyTitle, match with a glob pattern by default. To match differently, start the pattern with regexp: for a regular expression, or exact: for an exact match.
Example File
This example logs in on a login form and then checks that a logout link is present and that the URL matches. The file contains JavaScript comments, so as shown it isn’t strictly valid JSON.
{
"Type": "Recording",
"Version": "5.0",
"CreationDate": "2022-12-21",
"CreatedInIncognito": true,
"PluginVersion": "4.3",
"Name": "example.com-detectify-recording",
// Run this to reach a given state (i.e, authenticate as a user)
"Commands": [
{
"type": "UserAction",
"version": "1.0",
"command": "setViewport",
"selectors": [],
"values": ["2488", "1340"]
},
{
"type": "Selenium",
"version": "1.0",
"command": "open",
"selectors": [],
"values": ["https://example.com/login/"]
},
{
"type": "UserAction",
"version": "1.0",
"command": "input",
"selectors": [
["css=body > form > input[type=\"text\"]:nth-child(1)"],
["css=[type='text']"],
["css=input:nth-of-type(1)"],
["css=input[type='text']"]
],
"values": ["admin"]
},
{
"type": "UserAction",
"version": "1.0",
"command": "input",
"selectors": [
["css=body > form > input[type=\"password\"]:nth-child(2)"],
["css=[type='password']"],
["css=input:nth-of-type(2)"],
["css=input[type='password']"]
],
"values": ["password"]
},
{
"type": "UserAction",
"version": "1.0",
"command": "mouseClick",
"selectors": [
["css=body > form > button"],
["css=button"]
],
"values": []
},
{
"type": "Helper",
"version": "1.0",
"command": "sleep",
"selectors": [],
"values": ["5000"]
},
{
"type": "Extractor",
"version": "1.0",
"command": "defaults",
"selectors": [],
"values": []
}
],
// Will run sequentially in a loop once per minute, if the assertion fails re-run "Commands"
"SanityChecks": [
{
"type": "Selenium",
"version": "1.0",
"command": "verifyElementPresent",
"selectors": [["text=logout"]],
"values": []
},
{
"type": "Selenium",
"version": "1.0",
"command": "verifyURL",
"selectors": [],
"values": ["glob:http://example.com/login/"]
}
]
}After editing a file, upload it again and run a new validation. See Recorded Login.
Next Steps
- Recorded Login — Record, upload and validate a login
- Recorded Crawling — Replay user flows during a scan