My program can only scrap the top 9 of 40 elements in each result page. I suspect that it is likely because the rest of the 31 elements are not loaded until scrolling. I have found this topic on the forum: Scrolling webpage in Data Scraping
The solution is to use the Mouse Scroll, which is a modern activity. While it is possible to find a modern activity, when in the classic mode, one cannot use a modern activity, if the parent activity (e.g., Attach Browser) is a classic activity.
I have also seen the Send Hotkey solution. I tried this by using a loop to send a pgdn key eight times when the page is loaded before scraping. But it does not seem to have any effect.
I realized that with hover, when it did scroll down, it got the very last of the 40th as well. With this script, it did not seem to add anything beyond that. It got the first nine and the last of the forty.
So, all these seem to suggest that it requires scrolling down gradually than just jumping to the bottom of the page.
I shall add that the website to be scrapped has left and right part. The left is a map that does not scroll and the right is the result set that can scroll.
When using Hover and SetFocus, I did choose a selector on the bottom of the right. But I don’t know whether the script you wrote can detect the left/right setting.
Perhaps, the script can be mortified. Instead of scrolling to 5000 just one time, the script can be called 10 times, the each time the previous ending point (the second parameter in the scrollTo function) becomes the new starting point (the first parameter) and the new ending point increments by a number.
A quick answer is that it did not work. I put your code at the beginning of processing each result page. I did not see that the result page being scrolled down. I did not see more listings scrapped.
In addition, I have tried a few other things, but none worked, either.
In the loop processing each listing, I added an IF statement. In every 8 listing (1, 9, 17, 25, etc.), it will hover the 8th listing down (9, 17, 25, 33, etc.)