I am new to VBA Excel, but I would like to be able to create a macro to automate Edge to retrieve information on a specific page.
The goal is to know if the ClassName "colHead w3" appears or not on the page in question, I put the link of the HTML file so that you can know the location of this class (internal link inaccessible elsewhere, I have not find another way to post it).
I use the .QuerySelector , .GetElementsByClassName and .GetElementsByCss
But either I receive the error message "Error 424: Object required" or the error passes and shows me the incorrect result.
This is the code i use for test :
Sub runedge()
'Start Browser
Dim objBrowser As clsBrowser
Dim ws As Worksheet
Dim LastRow As Long
Dim Class As Object
Dim pst As Long
Set objBrowser = New clsBrowser
objBrowser.start "edge"
Set ws = ThisWorkbook.Sheets("Feuil1")
With ws
LastRow = ws.Range("A" & .Rows.Count).End(xlUp).row
For i = 2 To LastRow
'navigate
Call objBrowser.navigate("link")
objBrowser.wait till:="interactive"
'Call objBrowser.jsEval("document.getElementsByName(""value"")[0].value=""test""")
'run search
'Call objBrowser.jsEval("document.getElementsByName(""search"")[0].click()")
'wait till search has finished
'objBrowser.wait till:="interactive"
On Error GoTo 0
objBrowser.wait till:="interactive"
pst = ws.Cells(Rows.Count, "D").End(xlUp).row + 1
If objBrowser.jsEval("Document.queryselector("".colHead.w3"")[0]") > 0 Then
ws.Cells(pst, "D").Value = "Redeemed"
Else
ws.Cells(pst, "D").Value = "Free"
End If
Next
End With
objBrowser.show
End Sub
HTML File Link : https://www.mediafire.com/file/aa7m16xyrmvrmvt/SearchResults.do.html/file
Thank you for help :)