我试图滚动Google Maps窗口左侧的结果窗格,但我使用的这段代码没有滚动结果窗格,也没有显示任何错误.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
url = "https://www.google.com/maps/@12.959744,77.6142848,12z?entry=ttu"
driver = webdriver.Chrome()
driver.get(url)
driver.maximize_window()
time.sleep(15)
# find text_field and search for restaurants
search_box = WebDriverWait(driver,15).until(EC.presence_of_element_located((By.XPATH,"//input[@id = 'searchboxinput']")))
time.sleep(5)
search_box.send_keys("restaurants")
search_box.send_keys(Keys.RETURN)
time.sleep(12)
# scroll the result pane
results = WebDriverWait(driver,20).until(EC.presence_of_element_located((By.XPATH,'//div[@role="feed"]')))
time.sleep(10)
driver.execute_script('window.scrollTo(0,document.body.scrollHeight);')
time.sleep(8)
我怎样才能正确地做这件事?