Inspect page

bl expect

Assert page state; exits 0 on pass, 1 on failure

Assert page state; exits 0 on pass, 1 on failure

Usage

bl expect [OPTIONS]
bl expect <command>

Options

OptionDescription
--headlessHide browser window (visible by default)
--jsonOutput as JSON

Global options

OptionDescription
-v, --verboseEnable debug logging

bl expect url

Assert the current page URL

Usage

bl expect url <operator> <text> [OPTIONS]

Arguments

ArgumentDescription
&lt;operator&gt;Comparison: contains (substring) or equals (exact match)
&lt;text&gt;Expected URL or URL substring

Options

OptionDescription
--headlessHide browser window (visible by default)
--jsonOutput as JSON

Global options

OptionDescription
-v, --verboseEnable debug logging

Examples

bl expect url contains "/dashboard"
# Pass if the URL contains /dashboard

bl expect url equals "https://example.com/"
# Pass if the URL matches exactly

bl expect title

Assert the current page title

Usage

bl expect title <operator> <text> [OPTIONS]

Arguments

ArgumentDescription
&lt;operator&gt;Comparison: contains (substring) or equals (exact match)
&lt;text&gt;Expected title or title substring

Options

OptionDescription
--headlessHide browser window (visible by default)
--jsonOutput as JSON

Global options

OptionDescription
-v, --verboseEnable debug logging

Examples

bl expect title contains "Dashboard"
# Pass if the title contains Dashboard

bl expect text

Assert the text content of the page or an element

Usage

bl expect text <operator> <text> [OPTIONS]

Arguments

ArgumentDescription
&lt;operator&gt;Comparison: contains (substring) or equals (exact match)
&lt;text&gt;Expected text or text substring

Options

OptionDescription
--selector <value>CSS selector to scope the check to one element (defaults to full page text)
--headlessHide browser window (visible by default)
--jsonOutput as JSON

Global options

OptionDescription
-v, --verboseEnable debug logging

Examples

bl expect text contains "Welcome back"
# Pass if the page text contains it

bl expect text equals "Logout" --selector "#nav button"
# Pass if the element's text matches exactly

bl expect visible

Assert an element is visible

Usage

bl expect visible <selector> [OPTIONS]

Arguments

ArgumentDescription
&lt;selector&gt;CSS selector of the element

Options

OptionDescription
--headlessHide browser window (visible by default)
--jsonOutput as JSON

Global options

OptionDescription
-v, --verboseEnable debug logging

Examples

bl expect visible "#save"
# Pass if the element is visible

bl expect hidden

Assert an element is absent or not visible

Usage

bl expect hidden <selector> [OPTIONS]

Arguments

ArgumentDescription
&lt;selector&gt;CSS selector of the element

Options

OptionDescription
--headlessHide browser window (visible by default)
--jsonOutput as JSON

Global options

OptionDescription
-v, --verboseEnable debug logging

Examples

bl expect hidden ".spinner"
# Pass if the element is missing or not visible

bl expect enabled

Assert an element is enabled

Usage

bl expect enabled <selector> [OPTIONS]

Arguments

ArgumentDescription
&lt;selector&gt;CSS selector of the element

Options

OptionDescription
--headlessHide browser window (visible by default)
--jsonOutput as JSON

Global options

OptionDescription
-v, --verboseEnable debug logging

Examples

bl expect enabled "button[type=submit]"
# Pass if the button is enabled

bl expect checked

Assert a checkbox or radio is checked (or unchecked with --not)

Usage

bl expect checked <selector> [OPTIONS]

Arguments

ArgumentDescription
&lt;selector&gt;CSS selector of the checkbox or radio

Options

OptionDescription
--notAssert the element is NOT checked
--headlessHide browser window (visible by default)
--jsonOutput as JSON

Global options

OptionDescription
-v, --verboseEnable debug logging

Examples

bl expect checked "#terms"
# Pass if the box is checked

bl expect checked "#terms" --not
# Pass if the box is unchecked

bl expect value

Assert the value of a form element

Usage

bl expect value <selector> <operator> <text> [OPTIONS]

Arguments

ArgumentDescription
&lt;selector&gt;CSS selector of the form element
&lt;operator&gt;Comparison: contains (substring) or equals (exact match)
&lt;text&gt;Expected value or value substring

Options

OptionDescription
--headlessHide browser window (visible by default)
--jsonOutput as JSON

Global options

OptionDescription
-v, --verboseEnable debug logging

Examples

bl expect value "input[name=email]" equals "a@b.com"
# Pass if the input holds exactly that value

bl expect count

Assert the number of elements matching a selector

Usage

bl expect count <selector> <number> [OPTIONS]

Arguments

ArgumentDescription
&lt;selector&gt;CSS selector to count matches for
&lt;number&gt;Expected number of matches

Options

OptionDescription
--headlessHide browser window (visible by default)
--jsonOutput as JSON

Global options

OptionDescription
-v, --verboseEnable debug logging

Examples

bl expect count "li.item" 3
# Pass if exactly 3 items match

bl expect js

Assert a JavaScript expression evaluates truthy

Usage

bl expect js <expression> [OPTIONS]

Arguments

ArgumentDescription
&lt;expression&gt;JS expression; false, null, empty string, and 0 fail

Options

OptionDescription
--headlessHide browser window (visible by default)
--jsonOutput as JSON

Global options

OptionDescription
-v, --verboseEnable debug logging

Examples

bl expect js "document.querySelectorAll('.error').length === 0"
# Pass if no error elements are on the page

On this page