package com.seleniumtests.webpage;

import com.seleniumtests.webelements.ButtonElement;
import com.seleniumtests.webelements.PageObject;
import com.seleniumtests.webelements.TextFieldElement;

import org.openqa.selenium.By;


/**
 * Created by tarun on 3/22/16.
 */
public class LoginPage extends PageObject {

    private static final TextFieldElement userNameTextBox =
        new TextFieldElement("Username Textbox", By.name("username"));

    private static final TextFieldElement passwordTextBox =
        new TextFieldElement("Password Textbox", By.name("psw1"));

    private ButtonElement submitButton = new ButtonElement("submit Button",
            By.cssSelector("input~input[value='Submit']"));


    public LoginPage() throws Exception {
        super(userNameTextBox);
    }

    public LoginPage enterUserName(String userName) {
        userNameTextBox.clearAndType(userName);

        return this;
    }

    public LoginPage enterPassword(String password) {
        userNameTextBox.clearAndType(password);

        return this;
    }

    /**
     * Google Home Page is not part of seleniumtests.com but this how you can move from one page object to another
     * @return
     * @throws Exception
     */
    public GoogleHomePage clickSubmitButton() throws Exception {
        submitButton.click();

        return new GoogleHomePage();
    }
}

@@ -430,16 +430,25 @@
 username
+LoginPage
 %22));%0A%0A  
@@ -1050,24 +1050,127 @@
 his;%0A    %7D%0A%0A
+    public static boolean isUserNameDisplayed() %7B%0A        return userNameTextBox.isDisplayed();%0A    %7D%0A%0A
     /**%0A    

update element locator