shahin
Active Member
Hi there everyone!! Hope you all are doing fine. I got a problem accomplishing my little piece of code which is slightly different from what I usually ask for. I've used javascript function within vba code which is written in combination with selenium. I tried to scroll to the downmost portion of a lazy-loading webpage using the below code. However, when my script attempts to do so, an error pops up indicating "object required". I need to get to the bottom of that page. In every scroll, it displays 20 links. There are 1000 links in that page. How the loop of my script should be to do the trick? Here is the code I've written so far:
Code:
Sub Testing_scroll()
Dim driver As New WebDriver
driver.Start "chrome", "http://fortune.com/fortune500"
driver.get "/list/"
Do Until x = 1000
x = driver.ExecuteScript("window.scrollTo(0, document.body.scrollHeight);").Length
Loop
End Sub
Last edited: