title: Waiting for same XPATH used on different pages with Selenium
body: <p>I'm using Selenium Webdriver and have run into the following issue with my app under test.</p>
  
  <p>The app has multiple pages each with an appropriate ".page-title" element which contains the name of the page (e.g. "Other Documents").  As the tests navigate around the app they assert  that the browser is on the expected page using these elements before doing other stuff.  </p>
  
  <p>The issue is that if you click a button in the app which performs an action, then check that you're on the right page (e.g. check page-title element displays correct text), Webdriver doesn't wait for the action to be performed (e.g. new page load), it returns straight away and the test fails.</p>
  
  <p>If you add a short thread sleep (500ms) between performing the action and checking you're on the right page, then you get StaleElementReferenceException (some of the time) and if you add a large thread sleep the test passes (but not quite <em>all</em> the time).</p>
  
  <p>My aim is to reduce the flakiness of the tests, does anyone have a suggestion as to how I can do this without Thread.sleep?</p>