Reputation: 31
Below is the code which I'm using but I'm getting this error that:
object doesn't support this property or method
while using getElementsByClassName
.
The new 2 variable I'm using is not getting filled please help me out, do let me know if I'm doing it the wrong way.
Sub PopulateTasks()
'Variable Declaration
Dim ie As Object
Dim noTaskText As String
Set ie = CreateObject("InternetExplorer.Application")
url = "http://example/do/"
.Visible = True
.Navigate url
.Top = 50
.Left = 430
.Height = 400
.Width = 400
Do Until Not ie.Busy And ie.readystate = 4
DoEvents
Loop
End With
Set link = ie.Document.getElementsByTagName("a")
For i = 1 To 200
For Each l In link
If l.innertext = storyIds(i) Then
l.Click
Do Until Not ie.Busy And ie.readystate = 4
DoEvents
Loop
If InStr("No tasks have been defined.", ie.Document.Body.outerText) <> 0 Then
noTaskFound = True
End If
noTaskText = ie.Document.getElementsByClassName("highlighted_message")(0).innerText
If noTaskFound = True Then
End If
Next
ie.Document.getElementbyId ("")
Do Until Not ie.Busy And ie.readystate = 4
DoEvents
Loop
Next i
End Sub
Upvotes: 3
Views: 28112
Reputation: 42538
To get an element with the class name, I would use querySelector:
Set element = ie.Document.querySelector(".classname")
Debug.Print element.innerHTML
With your example:
txt = ie.Document.querySelector(".highlighted_message").innerText
If txt = "No tasks have been defined." Then
noTaskFound = True
Exit For
End If
Upvotes: 3