I want to automate invalid and valid credentials
<p>I am doing <a href="http://en.wikipedia.org/wiki/Selenium_%28software%29" rel="nofollow noreferrer">Selenium</a> automation with page factory design pattern for a web application. Now I want to do automate valid valid, invalid invalid, valid invalid credential for a login page. How is it?</p>

<p>My complete code is</p>

<pre><code>package com.docmgr.Pages;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.support.CacheLookup;
    import org.openqa.selenium.support.FindBy;
    import org.openqa.selenium.support.How;
    import org.openqa.selenium.WebElement;
    public class LoginPage
    {
        WebDriver driver;
        public LoginPage(WebDriver driver)
        {
            this.driver=driver;
        }
        @FindBy(how=How.NAME,using="username")
        @CacheLookup
        WebElement username;
        @FindBy(how=How.NAME,using="password")
        @CacheLookup
        WebElement password;
        @FindBy(how=How.CLASS_NAME,using="button")
        @CacheLookup
        WebElement button;
        @FindBy(how=How.LINK_TEXT,using="Forgot Password")
        @CacheLookup
        WebElement fp;
        public void login_Doc(String uid,String pas)
        {
            username.sendKeys(uid);
            password.sendKeys(pas);
            button.click();
        }
    }


    package com.docmgr.TestCases;

    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.support.PageFactory;
    import org.testng.annotations.Test;

    import com.docmgr.Pages.LoginPage;

    import Helper.BrowserFactory;

    public class LoginTest
    {
        @Test
        public void chechValidUser()
        {
            System.setProperty("firefox.webdriver.marionette","pathToGeckodriver");
            WebDriver driver=BrowserFactory.startBrowser("firefox","54.68.159.876/docmgr");
            LoginPage login=PageFactory.initElements(driver,LoginPage.class);
            login.login_Doc("jgsdg","123");
        }
    }

    package Helper;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    public class BrowserFactory
    {
        static WebDriver driver;
        public static WebDriver startBrowser(String browsName,String url)
        {
            if(browsName.equals("firefox"))
            {
                driver=new FirefoxDriver();
            }

            driver.manage().window().maximize();
            driver.get(url);
            return driver;
        }
    }
</code></pre>