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

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