hubcap wait

Wait for an element matching a CSS selector to appear in the DOM.

When to use

Use wait to block until an element matching a CSS selector exists in the DOM. Use waittext for text content. Use waitgone for element removal. Use waitfn for custom JavaScript conditions.

Usage

hubcap wait <selector> [--timeout <duration>]

Arguments

ArgumentTypeRequiredDescription
selectorstringYesCSS selector of the element to wait for

Flags

FlagTypeDefaultDescription
—timeoutduration30sMaximum wait time

Output

FieldTypeDescription
foundboolWhether the element was found
selectorstringThe selector that was matched
{"found":true,"selector":".modal"}

Errors

ConditionExit codeStderr
Missing selector argument1usage: hubcap wait <selector> [--timeout <duration>]
Chrome not connected2error: connecting to Chrome: ...
Element not found within timeout3error: timeout

Examples

Wait for a modal to appear:

hubcap wait '.modal'

Wait with a custom timeout:

hubcap wait '#results' --timeout 10s

Click a button and wait for a result element (chaining):

hubcap click '#submit' && hubcap wait '.result' --timeout 15s

Wait for an element then extract its text:

hubcap wait '.notification' && hubcap text '.notification'

See also

  • waittext - Wait for text content to appear on the page
  • waitgone - Wait for an element to be removed from the DOM
  • waitfn - Wait for a JavaScript expression to return truthy
  • waitload - Wait for the page load event
  • exists - Check if an element exists without waiting