我想滚动到页面的末尾,直到特定类型的元素开始。我能够在Selenium ide中选择该元素,但是当在python代码中使用时,它不会选择该元素。
我的Python代码是:
while (True):
browser.execute_script("window.scrollTo(0, document.body.scrollHeight);")
current = len(WebDriverWait(browser, 1).until(EC.presence_of_all_elements_located((By.CLASS_NAME, "_698"))))
try:
moreElement = WebDriverWait(browser, 2).until(EC.element_located_to_be_selected((By.CSS_SELECTOR, "div._5vf:nth-child(2)")))
print " more element is " + moreElement
break
except:
print " could not found more ELEMENT "
在上面的代码中,我希望在找到元素div._5vf:nth-child(2))
时滚动结束。