Solution 1) Scroll to the last item
I think the Vinay approach should work. However, the current form assumes that the item already exists on the page. I assume that the item you want is displayed only after scrolling far enough. So what you can do is scroll to the last element in the div.
Watir-webdriver
At Watir-Webdriver:
div_with_scroll = browser.div(:class => 'containerNode tabContentPane typeNavigationSingleChild') div_with_scroll.elements.last.wd.location_once_scrolled_into_view
Watir-classic
In Watir-Classic, it is different because it does not use selenium-webdriver:
div_with_scroll = browser.div(:class => 'containerNode tabContentPane typeNavigationSingleChild') div_with_scroll.elements.last.document.scrollIntoView
Solution 2) Use the ScrollTop property
Alternatively, if the above does not work, you can set the scrollTop property to move the scroll bar of the div element. This worked for the application I was working on, and contained only the content that was downloaded only after scrolling down.
Watir-webdriver
To move the scroll bar to the bottom, which theoretically should launch the content loaded below, set the scrollTop property to scrollHeight :
div_with_scroll = browser.div(:class => 'containerNode tabContentPane typeNavigationSingleChild') scroll_bottom_script = 'arguments[0].scrollTop = arguments[0].scrollHeight' div_with_scroll.browser.execute_script(scroll_bottom_script, div_with_scroll)
To return to the top, set scrollTop to 0.
div_with_scroll = browser.div(:class => 'containerNode tabContentPane typeNavigationSingleChild') scroll_top_script = 'arguments[0].scrollTop = 0' div_with_scroll.browser.execute_script(scroll_top_script, div_with_scroll)
You can also use any value between them, depending on where you need to go.
Watir-classic
In Watir-Classic, you can directly set scrollHeight :
div_with_scroll = browser.div(:class => 'containerNode tabContentPane typeNavigationSingleChild') #Go to bottom div_with_scroll.document.scrollTop = div_with_scroll.document.scrollHeight #Go to top div_with_scroll.document.scrollTop = 0