Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

226
Vistas
How to get children of HTML custom elements?

I'm writing a scraper with puppeteer and I need to fill the fields of a form built with Aura js. The problem is I'm not able to reach the input and password fields because they're inside a custom element:

<lightning-input class="input sfdc_usernameinput slds-form-element" data-aura-rendered-by="116:0" lightning-input_input-host=""><span lightning-input_input="" data-aria="" class="slds-assistive-text"></span><label lightning-input_input="" for="input-5" class="slds-form-element__label slds-no-flex slds-assistive-text">Username</label>
    <div lightning-input_input="" class="slds-form-element__control slds-grow">
        <input lightning-input_input="" type="text" id="input-5" aria-invalid="false" placeholder="Username" class="slds-input">
    </div>
</lightning-input>

And when I try:

await page.type('#input-5', 'myusername');

it throws the error:

Error: No node found for selector: #input-5

This is confirmed if I try document.getElementById('#input-5') in browser console.

So how do I get that input?

EDIT: Adding a screenshot that shows what happens here: the markup with children elements but no way to access to them.

custom element lightning-input with some debug

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The element you're looking for are encapsulated in the shadow DOM thus making them hidden from the normal DOM query methods.

You can still query them like this:

document.querySelector("lightning-badge").shadowRoot.querySelector('#input-5')

Example: on this Aura demo page I can get text of a lightning badge with this code:

document.querySelector("lightning-badge").shadowRoot.textContent

"Start Position"

This query can of course can be executed in a page.evaluate method with puppeteer as well.

about 4 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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda