selenium --- scroll bar in several ways

These types probably will, if there is more that I will not, emmmmmmmmmmm



Import webdriver the Selenium from
from selenium.webdriver.common.keys Import Keys # mouse
from selenium.webdriver.common.action_chains import ActionChains # keyboard
Import Time
Driver = webdriver.Chrome ()
driver.get ( "http://www.baidu. COM ")
# 2.10.1 browser developed by the scroll bar elements of the display window visible
'' '
driver.find_element_by_link_text (" news ") .click ()
E = driver.find_element_by_id (' Change-City ')
JS =' arguments [ 0] .scrollIntoView (); '
driver.execute_script (JS, E)
' ''
# 2.10.1 browser scroll bar is operated by a coordinate point in the form of
'' '
driver.find_element_by_link_text ( "news") .click ()
Time. SLEEP (2)
JS = 'the window.scrollTo (0,600)'
Driver.
execute_script (JS) '' '
# JS execution of the second scroll bar
driver.find_element_by_link_text ( "news") .click ()
the time.sleep (2)
JS = "1000 document.documentElement.scrollTop ="
driver.execute_script (JS)
'' '
# in the end portion of the rolling
js = "window.scrollTo (0 , document.body.scrollHeight); "
# driver.execute_script (JS)
# SLEEP (10)
# # scroll to the top
JS =" the window.scrollTo (0, 0); "
driver.execute_script (JS)
'' '

Guess you like

Origin www.cnblogs.com/zsplovezsp/p/12197094.html