title: moving onto the next page using selenium by python
body: <pre><code>url_main = &quot;https://comic.naver.com/webtoon/detail.nhn?titleId=131385&amp;no=292&quot;
  </code></pre>
  <p>This webpage has pagination for comments in the end. When I inspected the page, the buttons were compiled like below:</p>
  <pre><code>&lt;a href=&quot;#&quot; class=&quot;u_cbox_page&quot; data-action=&quot;page#move&quot; data-log=&quot;RPC.pgnum&quot;&gt;&lt;span class=&quot;u_cbox_num_page&quot;&gt;3&lt;/span&gt;&lt;/a&gt;
  </code></pre>
  <p>I want to click one of these buttons, so I tried</p>
  <pre><code>driver = webdriver.Chrome(driver_path)
  driver.get(url_main)
  driver.switch_to.frame('commentIframe')
  view_all_comments = driver.find_element_by_xpath('''//*[@id=&quot;cbox_module&quot;]/div/div[8]/a''')
  view_all_comments.click()
  page_buttons = driver.find_elements_by_css_selector(&quot;.u_cbox_page&quot;)
  page_buttons[2].click()
  </code></pre>
  <p>But it returns</p>
  <pre><code>StaleElementReferenceException: stale element reference: element is not attached to the page document
    (Session info: chrome=87.0.4280.88)
  </code></pre>
  <p>How can I fix this?</p>