Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

140
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda