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

233
Visualizações
Script to automate the passing credentials to next page

I have one URL which asks me to " click here to login" then the next page loads. once the next page loads I need to pass the credential. tried below script but didn't work

document.getElementsByClassName('click_hereTo_login')[0].click();

$( document ).ready(function() 
{ if document.location.href=="https://example.com/secondpage"
then {
  document.getElementById('id').value="12322";
document.getElementById('password').value="4444";
document.getElementsByClassName('login')[0].click();
}})

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

First of all your if is not written correctly. It should be:

if (document.location.href=="https://example.com/secondpage"){
    document.getElementById('id').value="12322";
    document.getElementById('password').value="4444";
    document.getElementsByClassName('login')[0].click();
}

The another problem here is, that your script runs from scratch on both pages. If you want to pass data from page to page without backend, you can use either query string or localstorage to store the data somewhere and then access it from another page.

let id = localStorage.getItem('id');

// get the input element 
let idInput = document.getElementById('id');

// check if we are one second page
if(idInput) {
    document.getElementById('id').value = id;
}

// Save id on login click
document.querySelector('.login').addEventListener('click', () => {
    localStorage.setItem('id', 1234);
});
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