How to do Paste(ctrl+v) in Playwright Typescript?

1.3k Views Asked by At

When I click on Copy Link hyperlink, link(url) is getting copied. I want to open new tab and past that copied url into the address bar?

How can I do that using Playwright?

I am using playwright with typescript.

In attached image, you can see copy link (hyperlink).

Thanks in advance.

I tried multiple ways to achieve it.

1

There are 1 best solutions below

1
On

Try this:

test('test no 1', async ({ context }) => {
    await page.locator("your-locator").click(); //click is used because of a lack of auto-waits for innerText() (more info: https://playwright.dev/docs/actionability)
    const urlText = await page.locator("your-locator").innerText(); // save copied url
    const pageOne = await context.newPage();
    await pageOne.goto(urlText); //open new tab using copied url
})