• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

241
Vistas
What is "elementHandle.contentFrame()" in PlayWright?

I just solved a problem using "elementHandle.contentFrame()", but not really know what's going on behind it. So, I was trying to select a DOM element and click on it. But I realized that I couldn't just simply do it like this when the element is wrapped inside a frame:

{
    await page.click('<element>');
}

So, I applied this method ("elementHandle.contentFrame()") and it works!

{
    const handle = await page.$('frame');
    const contentFrame = await handle.contentFrame();

    await contentFrame.click('<selector>');
}

Can someone explain to me the concept behind it? Thanks!

almost 3 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You don't have to use contentFrame, page.frame('frame-name') can give you a frame instance as well.

Basically you can think iframe is a page inside another page, so that you have to first find that frame if you want select the element inside a iframe

almost 3 years ago · Juan Pablo Isaza Denunciar

0

The handle you have in the handle variable represents iframe element inside the page. With that variable, you can read or manipulate that element in the same way you can do with any other DOM element on that page. But you can't access the HTML content that iframe rendered.

That's why, if you want to interact with the content inside that frame you need to get the frame using contentFrame.

almost 3 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda