Selenium Page down by ActionChains
<p>I have a problem using function to scroll down using PageDown key via Selenium's ActionChains in python 3.5 on Ubuntu 16.04 x64.</p>

<p>What I want is that my program scrolls down by PageDown twice, so it reaches bottom at the end and so I can have selected element always visible.
Tried making another function using Keys.END, but it did not work, so I assume it has something to do with ActionChains not closing or something.</p>

<p><strong>The function looks like this:</strong></p>

<pre><code>from selenium.webdriver.common.action_chains import ActionChains
</code></pre>

<p>...</p>

<pre><code>def scrollDown(self):
    body = browser.find_element_by_xpath('/html/body')
    body.click()
    ActionChains(browser).send_keys(Keys.PAGE_DOWN).perform()
</code></pre>

<p><strong>and I use it in another file like this:</strong></p>

<pre><code>mod.scrollDown()
</code></pre>

<p>The first time I use it, it does scroll down as would if PageDown key would be pressed, while another time nothing happens.
It does not matter where i call it, the second (or third...) time it does not execute.
Tried doing it manually and pressed PageDown button twice, works as expected.
Console does not return any error not does the IDE.</p>

<p>Maybe, if you think it has to do with the action chains you can just do it like this:</p>

<p>body = browser.find_element_by_css_selector('body')
body.send_keys(Keys.PAGE_DOWN)</p>

<p>Hope it works!</p>

python selenium ubuntu