您可以尝试以下代码向上滚动页面:
from selenium.webdriver.common.keys import Keysself.web_driver.find_element_by_tag_name('body').send_keys(Keys.HOME)
您可以向上滚动到所需元素的另一种方式(首选):
element = self.web_driver.find_element_by_xpath('SOME_XPATH') # you can use ANY way to locate elementcoordinates = element.location_once_scrolled_into_view # returns dict of X, Y coordinatesself.web_driver.execute_script('window.scrollTo({}, {});'.format(coordinates['x'], coordinates['y']))
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)