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

190
Visualizações
javascript: document.getElementById("id").value = 'test' doesn't work

I'm a technical tester and I'm trying to create a javascript that autofill a form with some data so I can automate this process. The code is very simple:

document.getElementById("id1").value = 'test'; 
document.getElementById("id2").value = 'test';
...

But in this form there is some Angular code that set some fields mandatory and as far as I see, it uses the class "form-control ng-untouched ng-pristine ng-invalid". The problem is after I run my javascript in the console it sets the value but when I click on the submit button (that trigger something which will write the data into the DB) it tells me that those fields are mandatory like I didn't actually fill the fields and if for example I manually add a letter in one of the fields, it takes this specific field as "filled" and it works.

For some reason the document.getElementById("id1").value = 'test' doesn't actually set the value in the field.

I hope it's clear, i'm not an expert of it but trying to learn and automate my tests. Is there something I can do using Javascript because I don't have contact with the Angular developer.

Right now what I have try is editing the class "form-control ng-untouched ng-pristine ng-invalid" to "form-control ng-untouched ng-pristine ng-valid". It removes the mandatory clause but it's only a visualization thing because still the issue

Thank you in advance

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