For AI agents and LLMs: a machine-readable index is available at llms.txt. A plain-Markdown version of any documentation page is available by appending .md to its URL.
Skip to main content

Clipboard Assertions

Clipboard assertions let you verify what a "Copy" button actually copied, extract copied values into variables, and confirm clipboard state after your test writes or clears it.

The Test Clipboard​

Every run uses an isolated test clipboard:

  • Your real clipboard is safe: the OS clipboard is never read and never written. Tests can't leak your copied data into results, and nothing you copy mid-run interferes with the test
  • Automatic capture: when the page copies something (a Copy button, Ctrl/Cmd+C on a selection), it lands in the test clipboard
  • One current entry: like a real clipboard, every copy or clipboard write replaces the previous content
  • Multi-format: a single entry can carry plain text, HTML, and an image together (e.g. a "Copy image" button)
  • Same behavior everywhere: headless, headed, and CI runs all behave identically

Planning for Multi-Step Tests​

Because the clipboard holds one entry at a time:

  • Verify a copied value immediately after the copy or write that produced it. A later clipboard write/clear replaces it
  • To check several copies, interleave: copy A → verify → copy B → verify

What You Can Query​

QueryDescription
text contentThe plain-text content of the clipboard ("" when empty)
HTML contentThe rich-text representation, when present
formats presentWhich content types the entry carries (text, HTML, image)
image presence/sizeWhether an image was copied, and its byte size

Example Assertions​

Verified
Click the "Copy link" button, then verify the clipboard contains "/invoice/42"
Verify the clipboard text is "INV-2026-042"
Verify an image was copied to the clipboard
Verify the clipboard text is empty

Example Extractions​

Verified
Click the Copy button, store the copied coupon code as 'coupon'
Store the clipboard text as 'copied_link'

Stored values work like any other variable. Fill {{coupon}} into a field later, or assert on it.

Writing and Pasting (actions)​

The clipboard isn't read-only. Objectives can also drive it. See Browser State Actions:

Verified
Write "John Tester" to the clipboard, click the message field, then paste from the clipboard

Tips​

  • Don't paste to verify: assert on the clipboard directly instead of pasting into a field and reading it back
  • Prefer positive phrasing for empties: "verify the clipboard text is empty" rather than "verify X is not on the clipboard"
  • Clipboard actions need a page loaded first. Navigate before writing or pasting

Terminal First Testing With Kane CLI

Natural language browser & mobile app tests right from terminal.

×
Schedule Your Personal Demo
Kane CLI terminal

Help and Support

Related Articles