You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用Python Selenium触发分页滚动事件直接跳转到指定页码?

Absolutely! You can skip the tedious process of clicking through pages one by one and jump straight to page 100 using Selenium—here's how to do it, based on the pagination code snippet you shared:

直接触发JS事件(最推荐方案)

Looking at your pagination buttons, each uses Event.fire() (from Prototype.js, it appears) to trigger the rich:datascroller:onscroll event with the target page number. Since page 100 won’t be rendered in the visible button bar, clicking a physical button isn’t feasible. Instead, we can directly execute the same JavaScript event that the buttons use.

Example Python Selenium Code:

from selenium import webdriver

# Initialize your browser driver (Chrome used here; adjust for Firefox/Edge as needed)
driver = webdriver.Chrome()
driver.get("your_target_page_url")

# Execute the JavaScript to trigger the page jump
driver.execute_script("""
# Locate the parent table of the pagination buttons (the element where the event is bound)
const scrollerContainer = document.querySelector('.rich-datascr-inact').closest('table');
# Fire the scroll event to jump to page 100
Event.fire(scrollerContainer, 'rich:datascroller:onscroll', {'page': '100'});
""")

Alternative: Standard Custom Event

If for some reason Event.fire() isn’t available in your page context (unlikely given your snippet), you can create and dispatch a standard custom event instead:

driver.execute_script("""
const scrollerContainer = document.querySelector('.rich-datascr-inact').closest('table');
const scrollEvent = new CustomEvent('rich:datascroller:onscroll', {
  detail: {'page': '100'}
});
scrollerContainer.dispatchEvent(scrollEvent);
""")
Bonus: URL Parameter Shortcut

Quick side note: If your application supports page navigation via URL parameters (e.g., ?page=100 appended to the URL), this is even faster:

current_url = driver.current_url
# Replace existing page parameter or add it to the base URL
new_url = current_url.split('?')[0] + '?page=100'
driver.get(new_url)

Just confirm your app handles URL-based page jumps before using this method!


内容的提问来源于stack exchange,提问作者daniboy000

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 09:13:07