Cypress: Chrome hangs when copying text to clipboard

Created on 8 Nov 2018  ·  9Comments  ·  Source: cypress-io/cypress

Current behavior:

Clipboard does not work in Chrome launched by Cypress:

  • clipboard copy shortcut (⌘+C) causes Chrome to hang
  • edit->cut/copy and debugger "copy as cURL" menu options do not modify system clipboard contents

Desired behavior:

Clipboard should work as normal when interacting with Cypress Chrome instance.

Steps to reproduce:

Select any text anywhere in a Chrome instance launched by Cypress (text on a page, console/debugger output, location bar, chrome preferences etc) then hit ⌘+C.

Versions

  • Cypress 3.1.1
  • macOS 10.13.6
  • Chrome 70.0.3538.77 (Official Build) (64-bit)

Most helpful comment

This might be related, I'm getting stuck after clicking a button that's supposed to copy to the clipboard. I know issue #311 is tracking copy/paste support and I'm fine if the copy function is a no-op for now but I'd still like to be able to click this button w/out needing any human interaction to move on to the next part of the test afterwards. Right now, I need to hit enter to click OK to move on.
Screen Shot 2019-03-12 at 8 57 39 AM

All 9 comments

I'm not able to reproduce this at all.

You are doing this copy/paste manually right? Not writing tests for cypress to do this? Could you record a video/gif of what you mean? Perhaps I'm not doing exactly what you're doing.

Yes you have understood the issue correctly. I don't think adding a video is going to add any value here. None of my team mates can reproduce this error either (all on Mac).

This might be related, I'm getting stuck after clicking a button that's supposed to copy to the clipboard. I know issue #311 is tracking copy/paste support and I'm fine if the copy function is a no-op for now but I'd still like to be able to click this button w/out needing any human interaction to move on to the next part of the test afterwards. Right now, I need to hit enter to click OK to move on.
Screen Shot 2019-03-12 at 8 57 39 AM

All I can suggest is to ensure you have all extensions disabled when trying the keyboard shortcut - it may be localized somehow to your machine since no one else is experiencing this exact behavior.

Unfortunately we have to close this issue as there is not enough information to reproduce the problem.

Please comment in this issue with a reproducible example and we will reopen the issue. 🙏

@bohendo Are you using copy-to-clipboard, by chance?
I stumbled upon the same behaviour in my app, and found that copy-to-clipboard has a fallback mechanism that will display exactly this alert box if it finds that execCommand does not work (as appears to be the case within cypress).

So I guess we need to wait until https://github.com/cypress-io/cypress/issues/2851 is fixed.

@tzimmermann Good call, I'm actually using react-copy-to-clipboard but it uses copy-to-clipboard under the hood. I'll keep an eye on #2851 👍

+1

If the copy-to-clipboard functionality is not important to what you are testing, you can stub out window.prompt so that your test will run without interruption.

https://docs.cypress.io/api/commands/stub.html#Replace-built-in-window-methods-like-prompt

// Disable window prompt which is used in link creation by copy-to-clipboard library
// This prompt pauses test execution during `cypress open`
cy.window().then(win => {
    cy.stub(win, 'prompt').returns('DISABLED WINDOW PROMPT');
});

You could probably also store the value passed to the prompt in a clipboard variable and read from it later on in your test.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tahayk picture tahayk  ·  3Comments

jennifer-shehane picture jennifer-shehane  ·  3Comments

verheyenkoen picture verheyenkoen  ·  3Comments

igorpavlov picture igorpavlov  ·  3Comments

weskor picture weskor  ·  3Comments