// Path: src/main/java/com/seleniumtests/core/CustomAssertion.java
// public static void assertThat(final String reason, final boolean assertion) {
//     if (SeleniumTestsContextManager.getThreadContext().isSoftAssertEnabled()) {
//         softAssertThat(reason, assertion);
//     } else {
//         MatcherAssert.assertThat(reason, assertion);
//     }
// }
// 
// Path: src/test/java/com/seleniumtests/webpage/LoginPage.java
// public class LoginPage extends PageObject {
// 
//     private static final TextFieldElement userNameTextBox = new TextFieldElement("Username Textbox",
//             locateByName("usernameLoginPage"));
// 
//     private static final TextFieldElement passwordTextBox = new TextFieldElement("Password Textbox",
//             locateByName("psw1"));
// 
//     private ButtonElement submitButton = new ButtonElement("submit Button",
//             locateByCSSSelector("input~input[value='Submit']"));
// 
//     public LoginPage() throws Exception {
//         super(userNameTextBox);
//     }
// 
//     public LoginPage enterUserName(final String userName) {
//         userNameTextBox.clearAndType(userName);
// 
//         return this;
//     }
// 
//     public LoginPage enterPassword(final String password) {
//         userNameTextBox.clearAndType(password);
// 
//         return this;
//     }
// 
//     public static boolean isUserNameDisplayed() {
//         return userNameTextBox.isDisplayed();
//     }
// 
//     /**
//      * 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();
//     }
// 
//     public GoogleHomePage enterLoginData(final User user) throws Exception {
//         return enterUserName(user.getUserName()).enterPassword(user.getPassword()).clickSubmitButton();
//     }
// }
// 
// Path: src/test/java/com/seleniumtests/webpage/RegistrationPage.java
// public class RegistrationPage extends PageObject {
// 
// 
//     // https://github.com/appium/appium/issues/13306 > w3c standard only declares css and xpath locators
//     private static final TextFieldElement firstNameTextbox = new TextFieldElement("First name text box",
//             locateByCSSSelector("input[name='firstname']"));
// 
//     private TextFieldElement lastNameTextbox = new TextFieldElement("Last name text box", locateByName("lastname"));
// 
//     private TextFieldElement userNameTextbox = new TextFieldElement("user name text box", locateByName("username"));
// 
//     private TextFieldElement pwd1NameTextbox = new TextFieldElement("password 1 text box", locateByName("psw1"));
// 
//     private TextFieldElement pwd2NameTextbox = new TextFieldElement("password 2 text box", locateByName("psw2"));
// 
//     private ButtonElement submitButton = new ButtonElement("submit Button",
//             locateByCSSSelector("input~input[value='Submit']"));
// 
//     public RegistrationPage(final boolean openPageURL) throws Exception {
//         super(firstNameTextbox, openPageURL ? SeleniumTestsContextManager.getThreadContext().getAppURL() : null);
//     }
// 
//     public RegistrationPage enterFirstName(final String firstName) {
//         firstNameTextbox.clearAndType(firstName);
// 
//         return this;
//     }
// 
//     public RegistrationPage enterLastName(final String lastName) {
//         lastNameTextbox.clearAndType(lastName);
// 
//         return this;
//     }
// 
//     public RegistrationPage enterUserName(final String userName) {
//         userNameTextbox.clearAndType(userName);
// 
//         return this;
//     }
// 
//     public RegistrationPage enterPassword(final String password) {
//         pwd1NameTextbox.clearAndType(password);
// 
//         return this;
//     }
// 
//     public RegistrationPage enterConfirmPassword(final String password) {
//         pwd2NameTextbox.clearAndType(password);
// 
//         return this;
//     }
// 
//     public LoginPage clickSubmitButton() throws Exception {
//         submitButton.click();
// 
//         return new LoginPage();
//     }
// 
//     public LoginPage submitValidRegistrationData(final User user) throws Exception {
//         return enterFirstName(user.getFirstName()).enterLastName(user.getLastName()).enterUserName(user.getUserName())
//                                                   .enterPassword(user.getPassword())
//                                                   .enterConfirmPassword(user.getPassword()).clickSubmitButton();
//     }
// 
// }


import com.seleniumtests.webpage.RegistrationPage;
import static com.seleniumtests.core.CustomAssertion.assertThat;
import static org.hamcrest.CoreMatchers.is;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.LinkedHashMap;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import com.seleniumtests.core.Filter;
import com.seleniumtests.core.SeleniumTestPlan;
import com.seleniumtests.dataobject.User;
import com.seleniumtests.util.SpreadSheetHelper;
import com.seleniumtests.util.internal.entity.TestEntity;
import com.seleniumtests.webpage.GoogleHomePage;
import com.seleniumtests.webpage.LoginPage;
    public void registerWithValidUserData(final TestEntity testEntity,
        final User user) throws Exception {

        new RegistrationPage(true).submitValidRegistrationData(user);
        assertThat("User Name text box is missing on Login Page!!!",
            LoginPage.isUserNameDisplayed(), is(true));

    }

    @Test(
        groups = { "registerWithInvalidUserData" },
        dataProvider = "loginData",
        description = "Register with Invalid login data"
    )
    public void registerWithInvalidUserData(final TestEntity testEntity,
        final User user) throws Exception {
        RegistrationPage registrationPage = new RegistrationPage(true);
        registrationPage.enterFirstName(user.getFirstName()).enterLastName(
            user.getLastName()).enterUserName(user.getUserName()).enterPassword(
            user.getPassword());
        assertThat(
            "User Name text box is shown despite not completing registration process!!!",
            LoginPage.isUserNameDisplayed(), is(true));

    }

    @Test(
        groups = { "loginTest" },
        dataProvider = "loginData",
        description =
// Path: src/main/java/com/seleniumtests/core/CustomAssertion.java
// public static void assertThat(final String reason, final boolean assertion) {
//     if (SeleniumTestsContextManager.getThreadContext().isSoftAssertEnabled()) {
//         softAssertThat(reason, assertion);
//     } else {
//         MatcherAssert.assertThat(reason, assertion);
//     }
// }
// 
// Path: src/test/java/com/seleniumtests/webpage/LoginPage.java
// public class LoginPage extends PageObject {
// 
//     private static final TextFieldElement userNameTextBox = new TextFieldElement("Username Textbox",
//             locateByName("usernameLoginPage"));
// 
//     private static final TextFieldElement passwordTextBox = new TextFieldElement("Password Textbox",
//             locateByName("psw1"));
// 
//     private ButtonElement submitButton = new ButtonElement("submit Button",
//             locateByCSSSelector("input~input[value='Submit']"));
// 
//     public LoginPage() throws Exception {
//         super(userNameTextBox);
//     }
// 
//     public LoginPage enterUserName(final String userName) {
//         userNameTextBox.clearAndType(userName);
// 
//         return this;
//     }
// 
//     public LoginPage enterPassword(final String password) {
//         userNameTextBox.clearAndType(password);
// 
//         return this;
//     }
// 
//     public static boolean isUserNameDisplayed() {
//         return userNameTextBox.isDisplayed();
//     }
// 
//     /**
//      * 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();
//     }
// 
//     public GoogleHomePage enterLoginData(final User user) throws Exception {
//         return enterUserName(user.getUserName()).enterPassword(user.getPassword()).clickSubmitButton();
//     }
// }
// 
// Path: src/test/java/com/seleniumtests/webpage/RegistrationPage.java
// public class RegistrationPage extends PageObject {
// 
// 
//     // https://github.com/appium/appium/issues/13306 > w3c standard only declares css and xpath locators
//     private static final TextFieldElement firstNameTextbox = new TextFieldElement("First name text box",
//             locateByCSSSelector("input[name='firstname']"));
// 
//     private TextFieldElement lastNameTextbox = new TextFieldElement("Last name text box", locateByName("lastname"));
// 
//     private TextFieldElement userNameTextbox = new TextFieldElement("user name text box", locateByName("username"));
// 
//     private TextFieldElement pwd1NameTextbox = new TextFieldElement("password 1 text box", locateByName("psw1"));
// 
//     private TextFieldElement pwd2NameTextbox = new TextFieldElement("password 2 text box", locateByName("psw2"));
// 
//     private ButtonElement submitButton = new ButtonElement("submit Button",
//             locateByCSSSelector("input~input[value='Submit']"));
// 
//     public RegistrationPage(final boolean openPageURL) throws Exception {
//         super(firstNameTextbox, openPageURL ? SeleniumTestsContextManager.getThreadContext().getAppURL() : null);
//     }
// 
//     public RegistrationPage enterFirstName(final String firstName) {
//         firstNameTextbox.clearAndType(firstName);
// 
//         return this;
//     }
// 
//     public RegistrationPage enterLastName(final String lastName) {
//         lastNameTextbox.clearAndType(lastName);
// 
//         return this;
//     }
// 
//     public RegistrationPage enterUserName(final String userName) {
//         userNameTextbox.clearAndType(userName);
// 
//         return this;
//     }
// 
//     public RegistrationPage enterPassword(final String password) {
//         pwd1NameTextbox.clearAndType(password);
// 
//         return this;
//     }
// 
//     public RegistrationPage enterConfirmPassword(final String password) {
//         pwd2NameTextbox.clearAndType(password);
// 
//         return this;
//     }
// 
//     public LoginPage clickSubmitButton() throws Exception {
//         submitButton.click();
// 
//         return new LoginPage();
//     }
// 
//     public LoginPage submitValidRegistrationData(final User user) throws Exception {
//         return enterFirstName(user.getFirstName()).enterLastName(user.getLastName()).enterUserName(user.getUserName())
//                                                   .enterPassword(user.getPassword())
//                                                   .enterConfirmPassword(user.getPassword()).clickSubmitButton();
//     }
// 
// }


// Path: src/test/java/com/seleniumtests/tests/RegistrationTest.java
import com.seleniumtests.webpage.RegistrationPage;
import static com.seleniumtests.core.CustomAssertion.assertThat;
import static org.hamcrest.CoreMatchers.is;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.LinkedHashMap;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import com.seleniumtests.core.Filter;
import com.seleniumtests.core.SeleniumTestPlan;
import com.seleniumtests.dataobject.User;
import com.seleniumtests.util.SpreadSheetHelper;
import com.seleniumtests.util.internal.entity.TestEntity;
import com.seleniumtests.webpage.GoogleHomePage;
import com.seleniumtests.webpage.LoginPage;

    public void registerWithValidUserData(final TestEntity testEntity,
        final User user) throws Exception {

        new RegistrationPage(true).submitValidRegistrationData(user);
        assertThat("User Name text box is missing on Login Page!!!",
            LoginPage.isUserNameDisplayed(), is(true));

    }

    @Test(
        groups = { "registerWithInvalidUserData" },
        dataProvider = "loginData",
        description = "Register with Invalid login data"
    )
    public void registerWithInvalidUserData(final TestEntity testEntity,
        final User user) throws Exception {
        RegistrationPage registrationPage = new RegistrationPage(true);
        registrationPage.enterFirstName(user.getFirstName()).enterLastName(
            user.getLastName()).enterUserName(user.getUserName()).enterPassword(
            user.getPassword());
        assertThat(
            "User Name text box is shown despite not completing registration process!!!",
            LoginPage.isUserNameDisplayed(), is(true));

    }

    @Test(
        groups = { "loginTest" },
        dataProvider = "loginData",
        description =
            "Login test to verify that google home page can be reached"