selenium+python使用JS处理页面滚动条,代码示例如下:
# 1.滚动到元素指定位置
price = driver.find_element_by_xpath('//*[@id="nav-5"]/div/ul/li[1]/div')
driver.execute_script("arguments[0].scrollIntoView();", price)
# 2.将页面左右滚动条拉到中间
driver.execute_script("scrollBy(0, 0-document.body.scrollWidht *1/2)")