Selenium with Python: First instance of the element is identified but the next occurance is ElementNotVisibleException
<p>I have the following Selenium Test for Python/Django application:</p>

<pre><code>class EmailRecordsTest(StaticLiveServerTestCase):

    def test_can_store_email_and_retrieve_it_later(self):
        self.browser.get(self.live_server_url)
        emailbox = self.browser.find_element_by_xpath("//form[@class='pma-subscribe-form']/input[1]")
        self.assertEqual(emailbox.get_attribute("placeholder"), 'Enter your Email')
        print("tested until here")
        print("The placeholder: ", emailbox.get_attribute("placeholder"))
        print(emailbox)
        emailbox.send_keys('vio@mesmerizing.com')
</code></pre>

<p>First occurance of emailbox is clearly identified as seen from the print runs and assert Equal for placeholder. The last instance of emailbox.send_keys throws following error:</p>

<pre><code> selenium.common.exceptions.ElementNotVisibleException: Message:
 Element is not currently visible and so may not be interacted with
</code></pre>

<p>Cannot find why the same element become Not Visible when using with send_keys.</p>

<p>The Html code being tested is as below:</p>

<pre><code>&lt;!-- Start footer --&gt;
  &lt;footer id="pma-footer"&gt;
    &lt;!-- start footer top --&gt;
    &lt;div class="pma-footer-top"&gt;
      &lt;div class="container"&gt;
        &lt;div class="pma-footer-top-area"&gt;
          &lt;div class="row"&gt;
            &lt;div class="col-lg-3 col-md-3 col-sm-3"&gt;
              &lt;div class="pma-footer-widget"&gt;
                &lt;h4&gt;News letter&lt;/h4&gt;
                &lt;p&gt;Get latest update, news &amp; offers&lt;/p&gt;
                &lt;form class="pma-subscribe-form"&gt;
                  &lt;input id="subscribe-email" type="email" placeholder="Enter your Email"&gt;
                  &lt;button class="btn btn-danger btn-md" type="submit"&gt;Subscribe!&lt;/button&gt;
                &lt;/form&gt;
              &lt;/div&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;!-- end footer top --&gt;
</code></pre>

<p>Kindly help.</p>

<p>Another option which worked in this case is that you scroll to the specific element (which was at the bottom of the page)and then use send_keys it works.</p>

<pre><code>emailbox = self.browser.find_element_by_xpath("//form[@class='mu-subscribe-form']/input[1]")
self.browser.execute_script("window.scrollTo(0, document.body.scrollHeight);")
emailbox.send_keys('vio@mesmerizing.com')
</code></pre>

python django selenium