title: Python3 Selenium Issue
body: <p>I want to scrape some comments via a <a href="https://hotels.ctrip.com/hotel/347422.html?isFull=F#ctm_ref=hod_sr_lst_dl_n_1_8" rel="nofollow noreferrer">Web page</a>. When I try to choose the goto button(change to next page) via Selenium, it always shows a pop-up window. I have tried to close the pop-up window using Selenium, but it still doesn't work. Could someone help me <strong>fix this issue</strong> and help me <strong>complete the next_page() function below</strong>? Many thanks!</p>
  <p>I have already complete the Function <strong>scrape_comments()</strong> . What I want to do is to complete Function <strong>next_page()</strong>.</p>
  <p>Here is my code.</p>
  <pre><code>from selenium import webdriver
  from selenium.webdriver.common.keys import Keys
  from selenium.webdriver.firefox.options import Options
  from selenium.webdriver.support import expected_conditions as EC
  from selenium.webdriver.support.wait import WebDriverWait
  from selenium.common.exceptions import TimeoutException
  from selenium.webdriver.common.by import By
  
  # url
  url = &quot;https://hotels.ctrip.com/hotel/347422.html?isFull=F#ctm_ref=hod_sr_lst_dl_n_1_8&quot;
  
  # User Agent
  User_Agent_List = [&quot;Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1216.0 Safari/537.2&quot;,
                     &quot;Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)&quot;,
                     &quot;Mozilla/5.0 (compatible; MSIE 10.0; Macintosh; Intel Mac OS X 10_7_3; Trident/6.0)&quot;,
                     &quot;Opera/9.80 (X11; Linux i686; U; ru) Presto/2.8.131 Version/11.11&quot;,
                     &quot;Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1216.0 Safari/537.2&quot;,
                     &quot;Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:16.0.1) Gecko/20121011 Firefox/16.0.1&quot;,
                     &quot;Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25&quot;]
  
  # Define the related lists
  Score = []
  Travel_Types = []
  Room_Types = []
  Travel_Dates = []
  Comments = []
  
  DEFINE_PAGE = 10
  
  def next_page():
      &quot;&quot;&quot;
      It is a function to execute Next Page function
      &quot;&quot;&quot;
      current_page = int(browser.find_element_by_css_selector('a.current').text)
  
      # First, clear the input box
      browser.find_element_by_id(&quot;cPageNum&quot;).clear()
      print('Clear the input page')
  
      # Second, input the next page
      nextPage = current_page + 1
      print('Next page ',nextPage)
      browser.find_element_by_id(&quot;cPageNum&quot;).send_keys(nextPage)
      
      # Third, press the goto button
      WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, '//*[@id=&quot;cPageBtn&quot;]')))
      browser.find_element_by_xpath('//*[@id=&quot;cPageBtn&quot;]').click()
  
  
  def scrape_comments():
      &quot;&quot;&quot;
      It is a function to scrape User comments, Score, Room types, Dates.
      &quot;&quot;&quot;
      html = browser.page_source
      soup = BeautifulSoup(html, &quot;lxml&quot;)
      scores_total = soup.find_all('span', attrs={&quot;class&quot;:&quot;n&quot;})
      # We only want [0], [2], [4], ...
      travel_types = soup.find_all('span', attrs={&quot;class&quot;:&quot;type&quot;})
      room_types = soup.find_all('a', attrs={&quot;class&quot;:&quot;room J_baseroom_link room_link&quot;})
      travel_dates = soup.find_all('span', attrs={&quot;class&quot;:&quot;date&quot;})
      comments = soup.find_all('div', attrs={&quot;class&quot;:&quot;J_commentDetail&quot;})
      # Save score in the Score list
      for i in range(2,len(scores_total),2):
          Score.append(scores_total[i].string)
      Travel_Types.append(item.text for item in travel_types)
      Room_Types.append(item.text for item in room_types)
      Travel_Dates.append(item.text for item in travel_dates)
      Comments.append(item.text.replace('\n','') for item in comments)
  
  if __name__ == '__main__':
  
      # Random choose a user-agent
      user_agent = random.choice(User_Agent_List)
      print('User-Agent: ', user_agent)
  
      # Browser options setting
      options = Options()
      options.add_argument(user_agent)
      options.add_argument(&quot;disable-infobars&quot;)
  
      # Open a Firefox browser
      browser = webdriver.Firefox(options=options)
      browser.get(url)
  
      #### My ISSUE #####
      browser.find_element_by_xpath('//*[@id=&quot;appd_wrap_close&quot;]').click()
  
      page = 1    
      while page &lt;= DEFINE_PAGE:
          scrape_comments()
          next_page()
      
      browser.close()
  </code></pre>
  <p>Thanks in advance!</p>