Dim WPage As Selenium.WebDriver, myUrl As String
Dim tObj As Object, myTim As Single, AColl As Object, BColl As Object
Dim noBB As Boolean, MI As Long
'
myTim = Timer
'Crea Driver:
' Set WPage = CreateObject("Selenium.EdgeDriver")
Set WPage = CreateObject("Selenium.CHRomedriver")
'
myUrl = "https://www.carousell.sg/search/toys?SearchId=GL7fvY&addrecent=true&canChangeKeyword=true&includeSuggestions=true&searchId=3XYjuS" '<<< YOUR Url
'
WPage.Get myUrl
WPage.Wait 500
Debug.Print "Page loaded", Format(Timer - myTim, "0.0")
'
'Search the menu container:
Set AColl = WPage.FindElementsByTag("div")
For I = 1 To AColl.Count
If InStr(1, AColl(I).attribute("style"), "top:", vbTextCompare) = 1 Then
Debug.Print "Found menus DIV, # " & I
Exit For
End If
Next I
MI = I
'...and click the second one:
Set tObj = AColl(MI).FindElementsByTag("svg")
tObj(2).FindElementByXPath("./..").Click
WPage.Wait 500
'Search the RadioButtons Container:
Set BColl = WPage.FindElementsByTag("div")
For I = 1 To BColl.Count
If InStr(1, BColl(I).attribute("style"), "left:", vbTextCompare) = 1 Then
Debug.Print "Found RadioButtons DIV, # " & I
Exit For
End If
Next I
'...and click the second one:
Set tObj = BColl(I).FindElementsByTag("input")
tObj(2).Click
WPage.Wait 500
Debug.Print "ZxZx", AColl(MI).Text
If InStr(1, AColl(MI).Text, "Recent", vbTextCompare) > 0 Then
Debug.Print "Recent has been selected"
noBB = False
Else
noBB = True
End If
Debug.Print "noBB=" & noBB
If noBB Then
AppActivate (Application.Caption)
MsgBox ("Selecting Recent failed; select it manually before closing the msgbox")
''Stop '<<< This is only for test
End If