scrollintoview is not scrolling to element (python)

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-22 01:54:45

问题


I am parsing the HTML of a website and I want selenium to scroll down to all the elements containing '5 days ago'. This is the code I have:

element = driver.find_elements_by_xpath(u"//*[contains(text(), '5 days ago')]")

for e in element:

    driver.execute_script("arguments[0].scrollIntoView();", element)


    time.sleep(SCROLL_PAUSE_TIME)
    if element=='5 days ago':
       break

It is not scrolling. Can someone help me with what I am doing wrong?

Thanks

来源:https://stackoverflow.com/questions/54308539/scrollintoview-is-not-scrolling-to-element-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!