0

How to copy the src URL inside the iframe, change it and navigate to the updated URL

iframe class="Hkk469u_YqP_JeDapvYp" src="https://apist.clin.com:3001/?client_process_id=f738067d-ea96-4405-b676-3c5f11547301_f642201b-bbb0-4c1b-bf8df59a80ea6684&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnQtaW5zcGVjbG9tMzhjZWQ3ODFhNmZkIiwiTmFtZSI6IlRlc3RpbmcgMiIsIm /iframe

await page.frameLocator('iframe').locator('').()

Niro
  • 9
  • 2
  • 1
    Why can't you just `await page.goto('new url here);` ? – AJG Mar 29 '23 at 12:35
  • The URL data inside the IFRAME changes every time, and I need to add text at the end of the URL &img_by_url=true – Niro Mar 30 '23 at 04:34

1 Answers1

0

You can try to manipulate the iframe src attribute in the following way, though it would be nice if Playwright had a locator.setAttribute('' '') method :)

const elementHandle = await page.$('.Hkk469u_YqP_JeDapvYp');
await elementHandle.evaluate((node) => node.setAttribute('src', 'your value here'));

It looks like your iframe class name could be dynamically generated so you may need another way to locate it.

HTH

AJG
  • 476
  • 2
  • 5