how to get all elements (visible and invisible)

557 views Asked by At

i stuck in list view where thousands of items but only 20 items show when i scroll down then 20 items more show and so on...

<ul class'python'>
    <li> item1 </li>
    <li> item2 </li>
    <li> item3 </li>
     .
     .
     .
    <li> item1000 </li>
</ul>

my code also get just show items, i want to get all visible and invisible items through selenium? how can i get that?

ul=driver.find_element_by_class('python')
for item in ul.find_elements_by_tag_name("li"): 
    print(item.text)
1

There are 1 answers

0
iFlo On BEST ANSWER

If your issue is just to scroll down the webpage, you could do :

driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")

For a more precise method, if you have the xpath of the next li elemen you want to get to, you can :

element=find_element_by_xpath("xpath of the li you are trying to access")
element.location_once_scrolled_into_view