Hi, Bro, thank you so much for your helping hand. Below is my rough script. error box appear during the selection under the condition field,
Sub Corousell_Run()
Dim WPage As Selenium.WebDriver, myUrl As String
Dim tObj As Object, myTim As Single, AColl As Object, BColl As Object, DColl As Object, FColl As Object
Dim noBB As Boolean, MI As Long
Dim NextR As Long, cCnt As Long, cCnt2 As Long
Dim NO1 As String
Dim NO2 As String
Dim LValue As String
Dim DataText As String
Dim anum As String
Dim WebsiteURLAddress As String
'
myTim = Timer
Set WPage = CreateObject("Selenium.CHRomedriver")
SearchProductItemEnd = Worksheets("sheet1").Cells(Rows.Count, 1).End(xlUp).Offset(-13, 0).Row
myUrl = "
smart watch - View all smart watch ads in Carousell Singapore" 'Your Url
Sheets("sheet2").Select '<<< The sheets that will be used
'
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"), "display:", 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")
Debug.Print tObj.Count
tObj(1).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("label")
Debug.Print tObj.Count
tObj(2).Click
WPage.Wait 500
'Debug.Print "D_FK", AColl(3).Text
Debug.Print ">ZxZx", tObj(2).Attribute("type"), tObj(2).Attribute("value")
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
WPage.Wait 500
'Look for the Products:
Debug.Print ">Let's search the Products", Format(Timer - myTim, "0.0")
'Scroll to end of page..
'WPage.ExecuteScript ("window.scrollTo(0, document.body.scrollHeight);")
WPage.Wait 1500
i = 0
skip:
Set tObj = WPage.FindElementsByTag("Main")(1)
'For PageRun = 1 To 10
Set DColl = tObj.FindElementsByTag("button")
Debug.Print DColl.Count
x = DColl.Count
If x > 38 Then
DColl(x).Click
WPage.Wait 5000
End If
d = 0
Set BColl = WPage.FindElementsByTag("div")
For i = 1 To BColl.Count
If InStr(1, BColl(i).Attribute("style"), "display:", vbTextCompare) = 1 Then
Debug.Print ">Found RadioButtons DIV # " & i
d = d + 1
If d < 10 Then
GoTo skip3
End If
Exit For
End If
skip3:
Next i
M2 = i
Set tObj = BColl(M2).FindElementsByTag("button")
Debug.Print tObj.Count
tObj(1).Click
d = 0
Set BColl = WPage.FindElementsByTag("div")
For i = 1 To BColl.Count
If InStr(1, BColl(i).Attribute("role"), "listbox", vbTextCompare) = 1 Then
Debug.Print ">Found RadioButtons DIV # " & i
d = d + 1
If d < 1 Then
GoTo skip4
End If
Exit For
End If
skip4:
Next i
M2 = i
Set tObj = BColl(M2).FindElementsByTag("button")
Debug.Print tObj.Count
'====================================Problem Start from here, error box appear, than allow it to work, you need to manually scroll all the way down the drop down menu then you will be enabled to click and that is the problem
tObj(1).Click
d = 0
Set BColl = WPage.FindElementsByTag("div")
For i = 1 To BColl.Count
If InStr(1, BColl(i).Attribute("data-testid"), "Brand new", vbTextCompare) = 1 Then
Debug.Print ">Found RadioButtons DIV # " & i
d = d + 1
If d < 1 Then
GoTo skip5
End If
Exit For
End If
skip5:
Next i
M2 = i
Set tObj = BColl(M2).FindElementsByName("class")
Debug.Print tObj.Count
BColl(M2).Click
d = 0
Set BColl = WPage.FindElementsByTag("div")
Debug.Print BColl.Count
For i = 1 To BColl.Count
If InStr(1, BColl(i).Attribute("id"), "ReactModalPortal-SearchFiltersBarMoreRightPanelDesktop", vbTextCompare) = 1 Then
Debug.Print ">Found RadioButtons DIV # " & i
d = d + 1
If d < 2 Then
GoTo skip6
End If
Exit For
End If
skip6:
Next i
M2 = i
Set tObj = BColl(M2).FindElementsByTag("button")
Debug.Print tObj.Count
tObj(3).Click
End Sub