I have this VBA code with Selenium WebDriver that extracts some text from SELECT OPTIONs. When I make a selection, the page reloads but my code does not wait for the page to load and gives an unexpected error. What should I do to make it wait until the page is loaded to move further?
Col = "I"
For Each Cel In SH.Range(Col & "2:" & Col & SH.Cells(SH.Rows.Count, Col).End(xlUp).Row)
Set CD = New Selenium.ChromeDriver
With CD
.Start
.Get "https://store.majic-paper.com/store/product-view.html/" & Cel.Value
Set Sizes = .FindElementByCss("#product").FindElementsByCss("option")
ReDim Arr(Sizes.Count)
x = 0
'making array of the options to be selected in next for each loop
For Each Size In Sizes
x = x + 1
Arr(x) = Size.Text
Next Size
For x = 1 To Sizes.Count
dr = dr + 1
dSH.Cells(dr, "A") = Cel.Value
dSH.Cells(dr, "B") = Arr(x)
Set sizez = .FindElementByCss("#product").AsSelect
sizez.SelectByText Arr(x) ' here as soon as it selects an item the page gets reloaded therefore do not give a chance to find the nam(Quantity) in next line
'Quantity
Set Q = .FindElementByName("Quantity").FindElementByCss("option")
dSH.Cells(dr, "C") = Q.Text