Joonyoung Park
Joonyoung Park

Reputation: 21

Google Survey Reviews popup iframe through Puppeteer

I'm trying to click a button from 'Google Customer Reviews' popup from Puppeteer, and almost out of luck to find a solution. The popup survey is imbedded into a website, and don't know how to select. Without clicking the button, can't proceed next steps since the frame itself is focused. (can't select the main page) I have tried a couple of solutions from multiple resources so far. For example, find selector from nested frames and pages. Looks like it's a dynamic javascript, so that can't select the frame by name or id. The following is a snip of codes. Debug output Google Customer Reviews

await page.waitForSelector('iframe')
const frameHandle = await page.$( 'iframe[src^="https://www.google.com/shopping/customerreviews"]')
await frame.waitForSelector(GOOGLE_SURVEY_SELECTOR, { visible: true })
await frame.click(GOOGLE_SURVEY_SELECTOR)

Any helps or suggestions will be appreciated. Thanks!

Upvotes: 0

Views: 223

Answers (1)

bujhmt
bujhmt

Reputation: 179

After many hours of trying, I did this)

If your problem is that the puppeteer does not see the pop-up element (for example, google c-wiz element), this means that the pop-up is another page embedded in the current site (latent iframe).

There are some ways to access it:

  1. const popUpFrame = page.mainFrame().childFrames().filter((frame) => // any page interface check)
  2. const popUpFrame = page.frames().filter((frame) => // condition)
  3. const popUpFrame = page.frames()[0].childFrames().filter((frame) => //condition)

Thanks Joonyoung Park

Have a good hunting!

Upvotes: 0

Related Questions