Skip to content

Instantly share code, notes, and snippets.

@KonnorRogers
KonnorRogers / capybara_read_spec.rb
Created April 22, 2021 21:26
Clipboard reading in Capybara
it "should read clipboard text" do
page.driver.browser.execute_cdp(
"Browser.setPermission",
{
origin: page.server_url,
permission: { name: "clipboard-read" },
setting: "granted",
})
clip_text = page.evaluate_async_script("navigator.clipboard.readText().then(arguments[0])")
expect(clip_text).to eq("copied text")