title: Selenium: how to ensure back() navigation works as expected across different sites?
body: <p>So I am concerned with </p>
  
  <pre><code>webdriver.navigate().back();
  </code></pre>
  
  <p>in particular. AFter reading <a href="https://stackoverflow.com/questions/1313788/how-does-the-back-button-in-a-web-browser-work">How does the Back button in a web browser work?</a></p>
  
  <p>it made me think of how can I make sure back button behaves as expected?</p>
  
  <p>Here's different ways of having "back" navigation. How would you go about detecting which approach to use? Listen to whether POST or GET is being made? Listen for AJAX requests and plan the appropriate plan?</p>
  
  <pre><code>a) navigate back() (essentially hitting back button in firefox)
  b) make GET request to the previous page url
  c) click on "return to results" on current page
  </code></pre>
  
  <p>with a) <code>back()</code> sometimes do not work correctly for AJAX sites with no breadcrumbs. or for POST search results for example where pressing back will prompt alert message.</p>
  
  <p>with b) my concern is that the url may not match up,</p>
  
  <p>ex) dynamic urls with unique hash sessionid parameters</p>
  
  <p><a href="http://www.aa.com/results.php?sessionid=29756293changeseverytime" rel="nofollow noreferrer">http://www.aa.com/results.php?sessionid=29756293changeseverytime</a></p>
  
  <p>So how do I create a contingency to make sure the back navigation works correctly as expected for a variety of web apps and sites (there are lot of variability in terms of how the back button will behave).</p>