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

[Question] Copy To Clipboard in Playwright #9019

Closed
rthi-rajan opened this issue Sep 20, 2021 · 4 comments
Closed

[Question] Copy To Clipboard in Playwright #9019

rthi-rajan opened this issue Sep 20, 2021 · 4 comments

Comments

@rthi-rajan
Copy link

I am automating an openfin application
I want to copy come content to clipboard.
I tried to use the WriteText method of Clipboard API (I saw it is supported in Chrome https://caniuse.com/?search=clipboard)
But it giving me an error

Below is my code
runtimeCDPConnection = await chromium.connectOverCDP({ endpointURL: '' })

    allContexts = runtimeCDPConnection.contexts()
    runtimeContext = allContexts[0];
  
    runtimeContext.grantPermissions(['clipboard-read', 'clipboard-write'])
    await runtimeContext.writeText("Abcd")
    var abc = await runtimeContext.readText()
    console.log(abc)

I am getting error
runtimeContext.writeText is not a function

page = await runtimeContext.pages()[0]
await page.writeText("Abcd")
var abc = await page.readText()
console.log(abc)

Again getting error
TypeError: page.writeText is not a function

Am I using it wrong? Could someone guide me to add content to clipboard

@rthi-rajan rthi-rajan changed the title Copy To Clipboard in Playwright [Question] Copy To Clipboard in Playwright Sep 20, 2021
@mxschmitt
Copy link
Member

We have a feature request for adding copy/paste clipboard support across all the browsers: #8114. Please upvote it there.

Regarding your example, there is no method called writeText in Playwright yet.

@rthi-rajan
Copy link
Author

Thanks Max. Is there any other solution to get text added to clipboard? Tried JSDOM they also don't support it

@mxschmitt
Copy link
Member

This is not yet possible. Merging into #8114

@SabFloki
Copy link

I am automating an openfin application I want to copy come content to clipboard. I tried to use the WriteText method of Clipboard API (I saw it is supported in Chrome https://caniuse.com/?search=clipboard) But it giving me an error

Below is my code runtimeCDPConnection = await chromium.connectOverCDP({ endpointURL: '' })

    allContexts = runtimeCDPConnection.contexts()
    runtimeContext = allContexts[0];
  
    runtimeContext.grantPermissions(['clipboard-read', 'clipboard-write'])
    await runtimeContext.writeText("Abcd")
    var abc = await runtimeContext.readText()
    console.log(abc)

I am getting error runtimeContext.writeText is not a function

page = await runtimeContext.pages()[0] await page.writeText("Abcd") var abc = await page.readText() console.log(abc)

Again getting error TypeError: page.writeText is not a function

Am I using it wrong? Could someone guide me to add content to clipboard

Hi - I am also automating openfin app. Locally launched from drive (.exe app ) , I am able to connect with CDP port 12565. But while launching openfin app via CLI, CDP port is changed and 12565 isnt connecting. How to find on which CDP openfin app is launching, so that with playwright connectOverCDP , I could connect it. This will help in CI run too.

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

3 participants