Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!