I am trying to use the scroll bar in IE to scroll down the page. I am using
self.driver.execute_script("window.scrollTo(0, 10000);")
When i run my test and it gets to the page it does not scroll. No error is shown, the page just does not scroll. I can scroll the scroll bar page manually. My Selenium Python script will not scroll it.
My code snippet to scroll is:
def scroll_up_and_down_using_the_scrollbar(self): # Using the scrollbar on the Data Previews view page scroll up and down the page
#self.driver.execute_script("window.scrollTo(0, 10)")
# scroll down the page iteratively with a delay
for _ in xrange(0, 10 + 1):
self.driver.execute_script("window.scrollTo(0, 10000);")
time.sleep(2)
If i use Firefox and inspect the scroll bar I can see some HTML for it. Do i need to get the element for the scroll bar before I can use the scroll bar?
The HTML is:
<div style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px;">
<div style="position: absolute; z-index: -32767; top: -20ex; width: 10em; height: 10ex; visibility: hidden;" aria-hidden="true"/>
<div style="position: absolute; overflow: hidden; top: 16px; right: 0px; bottom: 16px; width: 16px;">
<div class="GJPPK2LBI" tabindex="0" style="position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px;">
<input type="text" tabindex="-1" role="presentation" style="opacity: 0; height: 1px; width: 1px; z-index: -1; overflow: hidden; position: absolute;"/>
<img class="GJPPK2LBH" border="0" style="width: 16px; height: 11px; background: transparent url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAALCAYAAAB24g05AAABNklEQVR42o3SvU/CQBjHcf4N/klXXTRu4mIiTjroxgh9iSaUggP2JTHVFgYbaBls2rJIWjoh1J/PXUqFBIKXfPIkl963TXqVSrFOr25xXKsfxJ67uGugsrlOLm9QrYI2gVazyQmCUBAhiCJEIkkSkSHLMh6k3l/k6KzGDzPttsIpioJOp1NQoaoqut21LlrP5u5Av9/nNE3jdJ3ROdMwYJgGTNPE44u1O2BZFqw3C7b9Dtux4ThOaTAYcEOyFTiv35cB98OF67oYjcYYE29c8Dziw/fJZLIduG5IZeAzCBCQKAwRRiGiKCIxn/F0imlMaO4NzGYz8oUkSZCSJGUzRZqmmM/nJEOWZfsDi8WC+14uudWK8LlCnjM58p8cT9pGgP3T9T347+q9DrcvE9tgn3UIe/Pm4V+cw+BxAioP1AAAAABJRU5ErkJggg==") no-repeat scroll 0px 0px; top: 0px;" src="http://justin-pc.infoshare.local:8080/clearcore501/ClearCore/clear.cache.gif" onload="this.__gwtLastUnhandledEvent="load";"/>
</div>
</div>
My TestCase to call the scroll bar method:
class DataPreviewsPage_TestCase(BaseTestCase):
def test_a3_view_preview_crminvalid_odbc_and_test_scrollbar_up_and_down(self):
print "*** Test view_preview_crminvalid_odbc_and_test_scrollbar_up_and_down ***"
tool_bar = ToolbarPage(self.driver)
time.sleep(1)
data_previews_page = tool_bar.clickDataPreviews()
time.sleep(2)
data_previews_view_page = data_previews_page.click_view_link(Globals.datapreview_crminvalid_odbc_name)
time.sleep(10)
data_previews_view_page.scroll_up_and_down_using_the_scrollbar()
How can i click the scroll bar to scroll down the page in Selenium Python?
Thanks, Riaz