title: Detect when the selenium webdriver changes url in browser
body: <p>I need to detect when the url in the browser changes whether it was because of click on a link, a form post or I changed the url in code. </p>
  
  <p>I need it because I'm creating an object to represent the page and I need to dispose recreate it when the url changes. </p>
  
  <p>Here is what I have tried so far:</p>
  
  <pre><code>private string _pageUrl;
  protected T _page = default(T);
  protected T Page
  {
      get
      {
          if (_page == null || UrlHasChanged())
          {
              _page = GetPage&lt;T&gt;();
              SetPageUrl();
          }
          return _page;
      }
  }
  
  private bool UrlHasChanged()
  {
      var driver = Session.GetDriver();
      return driver.Url != _pageUrl;
  }
  
  public void SetPageUrl()
  {
      _pageUrl = Session.GetDriver().Url;
  }
  </code></pre>
  
  <p>This works in most cases but it fails when the test goes forward a page and then goes back to the initial page.</p>
  
  <p>I need a way to detect when the url changes so I can reset the _page field. </p>