hubcap forms

List all forms and their input fields on the current page.

When to use

Use forms to understand the structure of forms on a page before filling them programmatically with fill, select, or check. Returns each form’s action, method, and all of its input elements.

Usage

hubcap forms

Arguments

None.

Flags

None.

Output

FieldTypeDescription
formsarrayArray of form objects
forms[].idstringThe form’s id attribute
forms[].actionstringThe form’s action URL
forms[].methodstringThe form’s method (GET, POST, etc.)
forms[].inputsarrayArray of input field objects
countnumberTotal number of forms found
{
  "forms": [
    {
      "id": "login",
      "action": "/auth",
      "method": "POST",
      "inputs": [
        {"name": "username", "type": "text", "value": ""},
        {"name": "password", "type": "password", "value": ""},
        {"name": "remember", "type": "checkbox", "value": "on"}
      ]
    }
  ],
  "count": 1
}

Errors

ConditionExit codeStderr
Chrome not connected2error: connecting to Chrome: ...
Timeout3error: timeout

Examples

List all forms on the page:

hubcap forms

Discover the login form fields, then fill and submit:

hubcap forms | jq '.forms[] | select(.id == "login") | .inputs[].name'
hubcap fill "#username" "admin" && hubcap fill "#password" "secret" && hubcap click "button[type=submit]"

Count the total number of input fields across all forms:

hubcap forms | jq '[.forms[].inputs | length] | add'

See also

  • fill - fill in a form field
  • select - select an option in a dropdown
  • check - check a checkbox
  • tables - extract structured table data