hubcap frames

List all frames and iframes on the current page.

When to use

Use frames to discover all frames and iframes embedded in the page. Use the returned frame IDs with evalframe to execute JavaScript in a specific frame context.

Usage

hubcap frames

Arguments

None.

Flags

None.

Output

FieldTypeDescription
framesarrayArray of frame objects
frames[].idstringFrame identifier for use with evalframe
frames[].urlstringURL loaded in the frame
frames[].namestringThe frame’s name attribute
frames[].parentIdstringParent frame identifier (empty for main frame)
countnumberTotal number of frames found
{
  "frames": [
    {
      "id": "F1A2B3C4D5E6",
      "url": "https://example.com/widget",
      "name": "ad-frame",
      "parentId": "MAIN_FRAME_ID"
    }
  ],
  "count": 1
}

Errors

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

Examples

List all frames:

hubcap frames

Get the URL of each iframe:

hubcap frames | jq -r '.frames[].url'

Run JavaScript inside a specific frame:

FRAME_ID=$(hubcap frames | jq -r '.frames[0].id')
hubcap evalframe "$FRAME_ID" "document.title"

See also

  • evalframe - execute JavaScript in a specific frame
  • source - get the full HTML source of the main document