title: Robot Framework Click Button vs Submit Form
body: <p>I'm new to Robot Framework and stuck with quite simple login web page test using <code>SeleniumLibrary</code>:</p>
  
  <pre><code>*** Test Cases ***
  Valid Login
      Open Browser To Login Page
      Input Username    admin
      Input Password    test
      Submit Credentials
      Dashboard Page Should Be Open
      [Teardown]    Close Browser
  </code></pre>
  
  <p>Most of the keywords are irrelevant to the question, except</p>
  
  <pre><code>Submit Credentials
      Click Button    login-button
  Dashboard Page Should Be Open
      Location Should Be    ${DASHBOARD URL}
      Title Should Be    Dashboard
  </code></pre>
  
  <p>If I run this test, it will fail, because <code>Location Should Be</code> check is executed too early, while browser is still on the original login page. I found two solutions that work, but both seems to be conceptually wrong:</p>
  
  <ol>
  <li><p>Use <code>sleep</code></p>
  
  <pre><code>Submit Credentials
  sleep ${DELAY}
  Dashboard Page Should Be Open
  </code></pre>
  
  <p>In this case <code>${DELAY}</code> should be quite big (e.g. 10s) to be sure that page is definitely loaded or it may fail anyway. Also, I've read that best practice is to avoid sleeps. And I can't use some <code>Wait Until Page Contains</code>, because I don't know, whether login page will be loaded again with some error message or Dashboard page loaded in success.</p></li>
  <li><p>Use <code>Form Submit</code> instead of <code>Click Button</code>:</p>
  
  <pre><code>Submit Credentials
      Submit Form  login-form
  </code></pre></li>
  </ol>
  
  <p>The <code>Form Submit</code> works fine, but it's different from actually clicking a  button, because button may have some <code>onclick</code> handler that would prevent submitting a form.</p>
  
  <p>Using <code>Wait Until Keyword Succeeds</code> as suggested in some other threads doesn't seem to help, as <code>Click Button</code> succeeds right away.</p>