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

224
Visualizações
Get new elements once you click a buttom

I want to automate a process that requiere to download a file.

I have to do a search, specifing a string in a search box and then clicking buttom (called: "ctl00$MainContent$BtnBusqueda"). Once the results are showed, you can download an unique results to a file with a buttom (called: "BtnDescarga").

I already could input the string to the search box and perform the search with this (iterable to automate over a string array):

function setUUID(element, index, array) {
    document.getElementsByName("ctl00$MainContent$TxtUUID")[0].value=element;
    document.getElementsByName("ctl00$MainContent$BtnBusqueda")[0].click();
}

So, I can call that over a string array with: array.forEach(setUUID)

I tried to finish the problem downloading the file with this:

function setUUID(element, index, array) {
    document.getElementsByName("ctl00$MainContent$TxtUUID")[0].value=element;
    document.getElementsByName("ctl00$MainContent$BtnBusqueda")[0].click();
    document.getElementsByName("BtnDescarga")[0].click();
}

But I get:

Uncaught TypeError: Cannot read properties of undefined (reading 'click')
    at setUUID (<anonymous>:4:49)
    at Array.forEach (<anonymous>)
    at <anonymous>:1:7

I'm new in JavaScript but I barely understand that the element called "BtnDescarga" only appears when the search it's done, so, it "appends" to the document. Then, how before the search it doesnt exist, it can't be foundt.

So, any solution to this? Anyway to access to a new element in document that only appears when you click a buttom? or any better solution to this?

Thanks overall.

about 4 years ago · Juan Pablo Isaza
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