I'm in the middle of writing a script that enters details into a sign up form.
The first name field of the form has the following html code:
<input name="firstname" class="text-input" id="input-text-view328" aria-describedby="form-input-text-error-view307-required" type="text" maxlength="50" placeholder="" data-event="blur" data-view-value="" data-stickit-id="stickit_47" autocomplete="off">
I can't seem to get the script to enter a value for this field. I have tried each of the following and none seem to work:
Set Fname = IE.Document.getElementsByName("firstname")
Fname.Value = "John"
Set Fname = IE.Document.getElementsByClassName("text-input")
Fname.Value = "John"
Set Fname = IE.Document.getElementByID("input-text-view328")
Fname.Value = "John"
The error i get is
"run-time error '438': Object doesn't support this property or method"
Any idea what's going on here?
Since getElementsByName returns collection, you can access them with the index nos
IE.Document.getElementsByName("firstname")(0).Value = "John"
OR
Set Fname = IE.Document.getElementsByName("firstname")(0)
Fname.Value = "John"
OR
IE.Document.getElementByID("input-text-view328").Value = "John"
OR
IE.Document.querySelector("#input-text-view328").Value = "John"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.