I load an internet page and log in with myusername and mypassword using VBA.
I would like to write a search-term in an input field of the webpage using VBA.
Because there is no name and ID in the input field, I didn't succeed.
Here is my code :
Sub MyLogin()
Dim IE As InternetExplorer
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.navigate "https://www.example.com"
Do Until .readyState = 4
DoEvents
Loop
.document.all.Item("username").Value = "myusername"
.document.all.Item("password").Value = "mypassword"
.document.forms(0).submit
End With
Do Until IE.readyState = 4
DoEvents
Loop
Dim inputfield As HTMLInputElement
For Each inputfield In IE.document.getElementsByTagName("input")
If inputfield.Type = "text" Then inputfield.Value = "mysearch"
Next
Do Until IE.readyState = 4
DoEvents
Loop
End Sub
The HTML field I want to fill:
input class="input-inboxsearch form-control" type="text" value="" placeholder="Nom, email" maxlength="71"
How can I set the value of the input field?
getElementsByClassName ("input-inboxsearch form-control")instead,