title: Get URL after sending form with webdriverio
body: <p>I need to automate a sign in process test. I'm using <a href="http://webdriver.io/" rel="nofollow">webdriver.io</a> in order to do that.</p>
  
  <p>Here is my problem.</p>
  
  <p>I have this bizarre sign in process:</p>
  
  <ol>
  <li>I have to fulfil a form in a regular webpage</li>
  <li>After sending the form, I'll be redirected to an URL that <strong>does not</strong> exist, but it contains an access code in one of its query params</li>
  <li>Then I take this access code and send it to another location to obtain an access token.</li>
  </ol>
  
  <p>What I need is a way of programmatically complete step 2, since 1 and 3 I have already figured out.</p>
  
  <p>I'm trying like this:</p>
  
  <pre><code>var webdriverio = require('webdriverio');
  var options = {
      desiredCapabilities: {
          browserName: 'chrome'
      }
  };
  
  webdriverio
      .remote(options)
      .init()
      .url(myUrl)
      .title(function(err, res) {
          console.log('Title was: ' + res.value);
      })
      .setValue('#usuario', user)
      .setValue('#password', password)
      .submitForm('form', function(){
          this.url(function(err, res){
              console.log(res.value);
          });
          this.pause(5000, function(){
              this.end();
          });
      });
  </code></pre>
  
  <p>However, it seems like the callback for <code>submitForm</code> is called before the page gets loaded. This way, my log shows the very same URL I passed before.</p>
  
  <p>If I try like this:</p>
  
  <pre><code>.submitForm('form', function(){
      this.pause(5000, function(){
          this.url(function(err, res){
              console.log(res.value);
              this.end();
          });
      });
  });
  </code></pre>
  
  <p>I get this strange output:</p>
  
  <blockquote>
    <p>data:text/html,chromewebdata</p>
  </blockquote>
  
  <p>I know that a pause is not flawless in this context, but I could not find an asynchronous way of doing this.</p>
  
  <p>Can anyone help?</p>