title: Submitting a form in mechanize
body: <p>I'm having issues submitting the result of a form submission (I can submit a form, but I can't submit the form on the page that follows the first).</p>
  
  <p>I have:</p>
  
  <pre><code>browser = mechanize.Browser()
  browser.set_handle_robots(False)
  browser.open('https://www.example.com/login')
  browser.select_form(nr=0)
  
  browser.form['j_username'] = 'username'
  browser.form['j_password'] = 'password'
  req = browser.submit()
  </code></pre>
  
  <p>This works, as <code>print req</code> results in</p>
  
  <p>`</p>
  
  <pre><code>&lt;body onload="document.forms[0].submit()"&gt;
      &lt;noscript&gt;
          &lt;p&gt;
              &lt;strong&gt;Note:&lt;/strong&gt; Since your browser does not support JavaScript,
              you must press the Continue button once to proceed.
          &lt;/p&gt;
      &lt;/noscript&gt;
  
      &lt;form action="https://www.example.com/Shibboleth.sso/SAML2/POST" method="post"&gt;
          &lt;div&gt;
              &lt;input type="hidden" name="RelayState" value="cookie:95ca495c"/&gt;                
  
              &lt;input type="hidden" name="SAMLResponse" value="really long encoded value"/&gt;                
          &lt;/div&gt;
          &lt;noscript&gt;
              &lt;div&gt;
                  &lt;input type="submit" value="Continue"/&gt;
              &lt;/div&gt;
          &lt;/noscript&gt;
      &lt;/form&gt;
  
  &lt;/body&gt;
  </code></pre>
  
  <p>`</p>
  
  <p>But I get errors when I try to use <code>req.select_form(nr=0)</code></p>
  
  <p>I assume this is probably from something along the lines of how mechanize returns objects from <code>submit()</code> and that I'm going about this the wrong way.</p>
  
  <p>Any input or guidance would be appreciated :)</p>