I saw a page on How can I scroll a web page using selenium webdriver in python? it can help me to scroll down to page end, but it has problem on some website. when you run this, the product list will no load, but manually scroll to the Viewallbutton(report1)睇更多(180) and tap it, then scroll you can get all the product.
how can i fix it? i want to load all the product.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
from selenium.webdriver.chrome.options import Options
chrome_path = r'C:\Users\ecgoo\Desktop\program\Pycharm\chromedriver.exe'
driver = webdriver.Chrome(chrome_path, )
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--disable-popup-blocking")
driver.maximize_window()
driver.get("https://www.ztore.com/tc/category/group/snacks")
tabName = driver.find_element_by_link_text("零食新登場")
tabName.click()
time.sleep(1)
report1 = driver.find_element_by_xpath("/html/body/div[1]/div/div/div[3]/span/div/span")
print(report1)
report1.click()
time.sleep(10)
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(300)
driver.close()