title: php-webdriver: wait for browser response after submitting form using click()
body: <p>Aside from using <code>sleep()</code> in my test, I'm wondering if anyone knows of a better strategy to explicitly wait for a form submission (POST) to complete before continuing with my assertions. Here's a very condensed version of what my test looks like, using phpunit together <a href="https://github.com/facebook/php-webdriver/" rel="noreferrer">php-webdriver</a> from Facebook).</p>
  
  <pre><code>function test_form_submission()
  {   
      // setup
      $web_driver = new WebDriver();
      $session = $web_driver-&gt;session();
      $session-&gt;open('http://example.com/login');
  
      // enter data
      $session-&gt;element('css selector', 'input[name=email]')-&gt;value(array('value' =&gt; str_split('test@example.com')));
      $session-&gt;element('css selector', 'input[name=password]')-&gt;value(array('value' =&gt; str_split('testpassword')));
  
      // click button to submit form
      $session-&gt;element('css selector', 'button[name=submit]')-&gt;click();
  
      // How do I wait here until the click() above submits the form
      // so I can check that we correctly arrives at the destination below
      // without resorting to sleep()?
  
      // Confirm that login was successful because we landed on account page
      $this-&gt;assertSame('http://example.com/account', $session-&gt;url());
  
      // teardown
      $session-&gt;close();
  }
  </code></pre>