Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chrome hangs when copying text to clipboard #2739

Closed
ncjones opened this issue Nov 8, 2018 · 14 comments
Closed

Chrome hangs when copying text to clipboard #2739

ncjones opened this issue Nov 8, 2018 · 14 comments

Comments

@ncjones
Copy link

ncjones commented Nov 8, 2018

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)
@jennifer-shehane
Copy link
Member

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.

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Jan 28, 2019
@ncjones
Copy link
Author

ncjones commented Feb 12, 2019

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).

@bohendo
Copy link

bohendo commented Mar 12, 2019

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

@jennifer-shehane
Copy link
Member

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. 🙏

@jennifer-shehane jennifer-shehane removed the stage: needs information Not enough info to reproduce the issue label Apr 25, 2019
@tzimmermann
Copy link

@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 #2851 is fixed.

@bohendo
Copy link

bohendo commented Jun 6, 2019

@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 👍

@mxrguspxrt

This comment has been minimized.

@CoryDanielson
Copy link
Contributor

CoryDanielson commented Oct 8, 2019

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.

@cesarlima-hotmart
Copy link

It worked for me. Hope it helps.
sudodoki/copy-to-clipboard#88

@jenishgandhi7
Copy link

jenishgandhi7 commented Apr 13, 2022

@bohendo did you find solution for how to handle this clipboard prompt. i having same issue can you please help me out.

image

@ivanmjartan
Copy link

I have solution, copy-to-clipboard library do document.execCommand("copy") and this has to be in callback.

For my solution help use https://github.com/dmtrKovalenko/cypress-real-events#readme library and invoke button that do copy like ...

cy.get(selector).realClick();

@Yangfan2016
Copy link

Chrome version 87 with Cypress default Electron is OK

But there is a problem with the selection of Chrome 104. It seems that the new version limits the ability to copy scripts to the clipboard.

@jenishgandhi7
Copy link

I have solution, copy-to-clipboard library do document.execCommand("copy") and this has to be in callback.

For my solution help use https://github.com/dmtrKovalenko/cypress-real-events#readme library and invoke button that do copy like ...

cy.get(selector).realClick();

@ivanmjartan Thank you, your solution help me and working for me

@romanesss
Copy link

I have solution, copy-to-clipboard library do document.execCommand("copy") and this has to be in callback.

For my solution help use https://github.com/dmtrKovalenko/cypress-real-events#readme library and invoke button that do copy like ...

cy.get(selector).realClick();

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests