import time from selenium import webdriver from selenium.webdriver.common.by import By driver = webdriver.Chrome() driver.get("https://www.12306.cn/index/") driver.implicitly_wait(30) latest_ele = driver.find_element(by=By.XPATH, value="//a[@id='index_ads']") # 滑动窗口到元素可见位置,返回当前元素在页面的坐标位置 res = latest_ele.location_once_scrolled_into_view print(res) time.sleep(5) driver.quit()