Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
Puppeteer selector not being found

I am having an issue debugging why a query selector is not being clicked - I can search for it in chrome and also if use the document.querySelector() in the dev tools it finds the query, which makes me believe that it is right, however it is not pressing it and just times out

Click Method:

async function click(page, selector, timeout) {
await beforeAction(page, timeout);
await page.waitForSelector(selector);
await page.waitFor(200);
await page.click(selector);
}

Main Method That gets executed:

async function existingStart(page) {
await loadCookies(page);
await page.goto(
    "https://mc.s7.exacttarget.com/cloud/#app/Email/C12/Default.aspx?entityType=none&entityID=0&ks=ks%23Content"
    , {
        waitUntil: 'load',
        timeout: 0
    }
);
await page.waitFor(200);
const contentBuilderFrame = await findFrame(page, "contentbuilder");
const searchField = await contentBuilderFrame.$(".contentsearch > input");
searchField.focus();
await page.keyboard.type("20200903");
await page.waitFor(500);
await page.keyboard.press('Enter');
await page.waitFor(5000);
// Screenshot to check page state
await page.screenshot({

    path: "./screenshot.png",

    fullPage: true

});
await page.waitFor(500);
// Times out
await click(page, '#contentRepeater > div.repeater-viewport > div.repeater-canvas.scrolling > div > div > table > tbody > tr:nth-child(1) > td:nth-child(3) > div > div > div > div')

}

And if I call the find Iframe method before clicking on the selector:

await findFrame(page, "contentbuilder");

Nothing really happens and it errors with a JSHandler issue, has anyone had anything similar happen? Could it be that the issue is Iframes? The odd thing is that the searchField input and keypress goes through just fine. Moreover, it is the same iframe, so I shouldn't have to call findFrame two times.

beforeAction:

async function beforeAction(page, timeout) {
if (timeout != null) {
await page.waitFor(timeout);
}

var isLoading = await isPageLoading(page);

while (isLoading) {
await new Promise((resolve) => setTimeout(resolve, 1000));
isLoading = await isPageLoading(page);
 }
}
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Since we came up with the answer in the comments, I'm posting it here for other people who come across this question.

As the targeted selector is in an iframe (contentbuilder), the context to be passed as argument the function click is not page but the iframe element: contentBuilderFrame.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!