-2

While running the code

 def extract():
    driver = webdriver.Firefox()
    driver.get('http://example.com/')

    while True:
        elm = driver.find_element_by_link_text(">>").click()
        elm.click()

if __name__ == '__main__':
    extract()

Page loads and also click's the next button(link) and loads the next page, the newly loaded page also has the same link button but it's not clicking and,

Am getting error:

Traceback (most recent call last):
  File "C:\Users\Admin\sel\click_next.py", line 14, in <module>
    extract_top_news()
  File "C:\Users\Admin\sel\click_next.py", line 11, in extract_top_news
    elm.click()
AttributeError: 'NoneType' object has no attribute 'click'

This is the link button in which am trying to click

<li>
<a href='http://example.com/page.php?page=2'>&gt;&gt;</a>
</li>

What I am missing!

Sumithran
  • 6,217
  • 4
  • 40
  • 54

1 Answers1

1

You do like a double click, because:

        elm = driver.find_element_by_link_text(">>").click()
        elm.click()

is like

driver.find_element_by_link_text(">>").click().click()

so just delete the first .click()