title: selenium: How to get page source code after clicking a button
body: <p>I'm using selenium with python to test my web server. What I need is to fill text in an input-text and click a button to submit messages to my server and open a new web page.<br></p>
  
  <p>Here is my code:<br></p>
  
  <pre><code>from selenium import webdriver
  from selenium.webdriver.common.by import By
  
  driver = webdriver.Chrome()
  driver.get("http://www.example.com")
  txt = driver.find_element_by_id('input-text')
  txt.clear()
  txt.send_keys('some messages')
  btn = driver.find_element_by_id('input-search')
  btn.click()
  # How to print the source code of the new page here?
  # I think it should be as below but I don't know how to do it:
  # driver.get("new link")   &lt;---- How to get the new link?
  # print(driver.page_source.encode('utf-8'))
  </code></pre>
  
  <p>When I execute the python code above, everything works fine:<br></p>
  
  <blockquote>
    <p>www.example.com is opened.<br> The <code>some messages</code> are filled in the
    input-text.<br> The button input-search is clicked.<br> The new web
    page is opened.</p>
  </blockquote>
  
  <p>Now I need to print the page source code of the new web page, which is opened by clicking the button, but I don't know how to do this.<br></p>
  
  <p><code>print(driver.page_source.encode('utf-8'))</code> just gives me the source code of <code>www.example.com</code>, instead of the new web page.</p>