title: Protractor- Generic wait for URL to change
body: <p>In previous questions I have seen that a nice way to wait for the url to change is to use:</p>
  
  <pre><code>browser.wait( function() {
      return browser.getCurrentUrl().then(function(url) {
          return /myURL/.test(url);
      });
  }, 10000, "url has not changed");`
  </code></pre>
  
  <p>But I am trying to have a method that I can pass myURL as a variable (in case I need to use it with other sites) and is not working.</p>
  
  <p>I am trying this in my Page Object file:</p>
  
  <pre><code>this.waitUrl = function(myUrl) {
      browser.wait( function(myUrl) {
          return browser.getCurrentUrl().then(function(url, myUrl) {
              return myUrl.test(url);
          });
      }, 10000, "url has not changed");
  };
  </code></pre>
  
  <p>Any ideas if this is even possible and how to do it if so?</p>