-
Notifications
You must be signed in to change notification settings - Fork 130
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
Prompt on cypress #88
Comments
I guess just disabling fallback might be an okay~ish thing for such case, if you don't need to test successful copying. Then either using fork right now from https://github.com/sudodoki/copy-to-clipboard/pull/82/files or waiting for it to be merged, which also needs some readme/typing updates |
In fact, i'm testing if the text is successfully copied to clipboard. |
@cesarlima-hotmart then you might be in trouble 😬 see https://github.com/sudodoki/copy-to-clipboard/tree/master/tests and https://github.com/sudodoki/copy-to-clipboard/blob/master/e2e_helpers/assertions/assertBuffer.js for possible references. I used extra elements to do 'reseting' of the buffer by calling ctrl/cmd+c with some text selected and pasted stuff into textarea/etc to verify I was able to copy something from buffer and that stuff I needed was copied. |
Yeah, cypress runs on chromium, but i think the problem is the app runs in a webview inside it. The weird thing is, in this cypress webview, it works if I click manually on the button that calls the copy, but it prompts if i click on it by the cypress click command. |
there're some issues with security which might be in play, as execCommand cannot be executed without user's interaction, not sure whether that's the case here |
The solution i've found is check the parameters of the alert and assume that it is going to be the copied value in the real scenario. cy.window().then(win => {
cy.stub(win, 'prompt').returns(win.prompt).as('copyToClipboardPrompt');
});
let link: string;
cy.get('.transmission-info-container .info .column:last-child .link').find('a').then($a => {
link = $a.text().trim();
});
cy.get('.transmission-info-container .info .column:last-child .link > div').click();
cy.get('@copyToClipboardPrompt').should('be.called');
cy.get('@copyToClipboardPrompt').should(prompt => {
expect(prompt.args[0][1]).to.equal(link);
}); |
Thank you! |
@cesarlima-hotmart |
@cesarlima-hotmart thanks, it works fine in cypress test runner, but when I run it as a node module in Electron( by command |
God bless you man! |
@cesarlima-hotmart |
@inoutw Did you ever find a solution to to your assertion error? I'm having similar issues Update: Turns out what happens is that Electron does not support alerts, so the "prompt" action didn't register.
|
Prompt alert when testing the application with cypress. Is there a way to solve it?
The text was updated successfully, but these errors were encountered: