package org.schoellerfamily.gedbrowser.selenium.pageobjects;

import org.openqa.selenium.WebElement;

/**
 * @author Dick Schoeller
 */
public class LoginPage extends PageBase {
    /**
     * @param factory the factory for creating pages as we navigate
     * @param previous the previous page
     * @param baseUrl the base URL of the site
     */
    public LoginPage(final PageFactory factory, final PageBase previous,
            final String baseUrl) {
        super(factory, previous, baseUrl, "login");
    }

    /**
     * @param username the username to enter
     * @param password the password to enter
     * @return the page we got here from
     */
    public PageBase login(final String username, final String password) {
        getWebElement("input[name='username'").click();
        getWebElement("input[name='username'").clear();
        sendText("input[name='username']", username);
        getWebElement("input[name='password'").click();
        getWebElement("input[name='password'").clear();
        sendText("input[name='password']", password);
        final WebElement webElement = getWebElement("input[value='Login']");
        webElement.click();
        final String temp =
                getPrevious().getBaseUrl() + getPrevious().getLocation();
        System.out.println("+++++++++++++++++++++++++++++");
        System.out.println("+++++++++++++++++++++++++++++");
        System.out.println("+++++++++++++++++++++++++++++");
        System.out.println(temp);
        System.out.println("+++++++++++++++++++++++++++++");
        System.out.println("+++++++++++++++++++++++++++++");
        System.out.println("+++++++++++++++++++++++++++++");
        waitForPageLoaded();
        return getPrevious();
    }
}

@@ -1181,499 +1181,139 @@
     
-final String temp =%0A                getPrevious().getBaseUrl() + getPrevious().getLocation();%0A        System.out.println(%22+++++++++++++++++++++++++++++%22);%0A        System.out.println(%22+++++++++++++++++++++++++++++%22);%0A        System.out.println(%22+++++++++++++++++++++++++++++%22);%0A        System.out.println(temp);%0A        System.out.println(%22+++++++++++++++++++++++++++++%22);%0A        System.out.println(%22+++++++++++++++++++++++++++++%22);%0A        System.out.println(%22+++++++++++++++++++++++++++++%22
+PageBase previous = getPrevious();%0A        final String expectedURL =%0A                previous.getBaseUrl() + previous.getLocation(
 );%0A 
@@ -1337,16 +1337,27 @@
 eLoaded(
+expectedURL
 );%0A     
@@ -1366,29 +1366,24 @@
  return 
-getP
+p
 revious
-()
 ;%0A    %7D%0A

make wait explicit