title: Return a page reference as result of action on page?
body: <p>I am using <code>LoadableComponent&lt;T&gt;</code> in a Selenium testing project. I have an application with a main page (modeled as <code>MainPage.java</code>) from which I go to login page (<code>LoginPage</code>). I enter some credentials and the login form is redirecting me (if credentials are valid) to the <code>MainPage</code> again, enabling some extra functionalities. Because I use <code>MainPage</code> as starting point for many tests, I had to implement <code>load()</code> method for <code>MainPage</code> with a valid URL. So if I am doing something like:</p>
  
  <pre><code>MainPage mainpage=new MainPage();
  mainpage.get();
  LoginPage loginPage=mainpage.clickLogin();
  loginPage.setUser("whatever").setPassword("totally_secret");
  mainpage = loginPage.clickJoin();
  mainpage.get();
  </code></pre>
  
  <p>I cannot be sure if the action which directs me to the <code>mainpage</code> was succesful or not, because anyway, the last call will load the page. On the other hand if I call <code>clickJoin()</code> method without assigning the returned object to a variable, I cannot validate if the correct page is loaded and I cannot get a reference to its methods in order to continue the test. I could also make <code>clickJoin()</code> method return void, but then how do I get the reference to the new page in the test?
  How should I deal with it? </p>