clipboard icon indicating copy to clipboard operation
clipboard copied to clipboard

Cannot use Clipboard on Browserstack and/or headless automation tests

Open celonicolosi opened this issue 5 years ago • 3 comments

I'm trying to use Clipboard on my automated tests. I'm clicking a button that copies text to clipboard but it's not working when I ran the tests on Browserstack and/or when I ran the tests headless! It keeps getting my system clipboard instead.

celonicolosi avatar Oct 21 '20 09:10 celonicolosi

Hi @celonicolosi,

could you provide some more info, like what goes into the clipboard, and what is expected to be returned?

janlelis avatar Dec 30 '20 20:12 janlelis

@janlelis I can show you such a test: https://github.com/selenide-examples/selenide-browserstack/blob/main/src/test/java/org/selenide/bs/ClipboardTest.java

This test

  1. clicks a button (on a web page) that copies some text to a clipboard,
  2. verifies that clipboard contains the expected text.

The problem is that

  • step 1 operates with clipboard on remote machine (where BrowserStack browser is running), but
  • step 2 operates with local clipboard (where the test is running).

To make it possible, you should create some API in BrowserStack that would give access to clipboard on the "browser" machine. Look how it's done in Selenoid: https://github.com/aerokube/selenoid/blob/master/docs/clipboard.adoc

asolntsev avatar Dec 16 '23 17:12 asolntsev

Although I am not sure if this in the scope or responsibility of this gem, it would be great if there is an easy-to-use way to do clipboard-tests in your CI. Did someone get this right, maybe with the described solution in @asolntsev comment?

janlelis avatar Apr 04 '24 16:04 janlelis