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

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

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 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