// Path: src/main/java/com/test/java/webui/project/WebDriverPlus.java
// public class WebDriverPlus {
//     private WebDriver driver;
//     private JavascriptExecutor jse;
//     private WebDriverWait wait;
//     private static final String FIREFOX = "firefox";
// 
//     public WebDriverPlus() {
//         this(FIREFOX);
//     }
// 
//     public WebDriverPlus(String browser) {
//         if (browser.equals("IE")) {
//             System.setProperty("webdriver.ie.driver", System.getProperty("user.dir") + File.separator + "driver" + File.separator + "IEDriverServer2.48.exe");
//             driver = new InternetExplorerDriver();
//         } else if (browser.equals("chrome")) {
//             System.setProperty("webdriver.chrome.driver",System.getProperty("user.dir") + File.separator + "driver" + File.separator + "chromedriver2.20.exe");
//             driver = new ChromeDriver();
//         } else {
//             System.setProperty("webdriver.firefox.bin", "D:\\Program Files\\Mozilla Firefox\\firefox.exe");
//             driver = new FirefoxDriver();
//         }
// 
//         jse = (JavascriptExecutor) driver;
//         wait = new WebDriverWait(driver, 10);
//         System.out.println("driver setted up");
//     }
// 
//     public WebDriver getDriver() {
//         return driver;
//     }
// 
//     public void setDriver(WebDriver driver) {
//         this.driver = driver;
//     }
// 
//     public WebDriverPlus get(String url) {
//         driver.get(url);
//         return this;
//     }
// 
//     public String getTitle() {
//         return driver.getTitle();
//     }
// 
//     public WebDriverWait getWait() {
//         return wait;
//     }
// 
//     public JavascriptExecutor getJse() {
//         return jse;
//     }
// 
//     public void randomAction() {
//         Actions actions = new Actions(driver);
//         actions.sendKeys(Keys.PAGE_DOWN).build().perform();
//     }
// 
//     public void quit() {
//         driver.quit();
//     }
// 
// 
// 
//     /*public WebElement findElement(By locator) {
//         if (isElementPresent(locator)) {
//             return driver.findElement(locator);
//         }
//         return null;
//     }
// 
//     public WebElement findElement(By locator, String text) {
//         if (isElementMatch(locator, text)) {
//             return driver.findElement(locator);
//         }
//         return null;
//     }
// 
//     public boolean isElementPresent(By locator) {
//         try {
//             WebElement result = wait.until(ExpectedConditions.presenceOfElementLocated(locator));
//             if (null != result) {
//                 return true;
//             }
//         } catch (Exception e) {
//             e.printStackTrace();
//             return false;
//         }
//         return false;
//     }
// 
//     public boolean isElementMatch(By locator, String text) {
//         return wait.until((ExpectedConditions.textToBePresentInElementLocated(locator, text)));
//     }*/
// }


import com.test.java.webui.project.WebDriverPlus;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.How;
package com.test.java.webui.project.Page;


/**
 * Created by beigui on 2016/5/24.
 */
public class LoginPage extends AbstractBasePage {
    public LoginPage(WebDriverPlus webDriverPlus) {
        super(webDriverPlus);
    }

    @FindBy(how = How.ID, using = "userName")
    WebElement username;

    @FindBy(how = How.ID, using = "password")
    WebElement password;

    @FindBy(how = How.ID, using = "submit")
    WebElement submit;

    @FindBy(how = How.ID, using = "usernameHtml02")
    WebElement usernameCheckpoint;

    public void typeUsername(String _username) {
        username.clear();
        username.sendKeys(_username);
    }

    public void typePassword(String _password) {
        password.clear();
        password.sendKeys(_password);
    }

    public boolean isLoginedIn(String text) {
        return textToBePresent(usernameCheckpoint, text);
    }

    public void login() {
        System.out.println("开始登录");
// Path: src/main/java/com/test/java/webui/project/WebDriverPlus.java
// public class WebDriverPlus {
//     private WebDriver driver;
//     private JavascriptExecutor jse;
//     private WebDriverWait wait;
//     private static final String FIREFOX = "firefox";
// 
//     public WebDriverPlus() {
//         this(FIREFOX);
//     }
// 
//     public WebDriverPlus(String browser) {
//         if (browser.equals("IE")) {
//             System.setProperty("webdriver.ie.driver", System.getProperty("user.dir") + File.separator + "driver" + File.separator + "IEDriverServer2.48.exe");
//             driver = new InternetExplorerDriver();
//         } else if (browser.equals("chrome")) {
//             System.setProperty("webdriver.chrome.driver",System.getProperty("user.dir") + File.separator + "driver" + File.separator + "chromedriver2.20.exe");
//             driver = new ChromeDriver();
//         } else {
//             System.setProperty("webdriver.firefox.bin", "D:\\Program Files\\Mozilla Firefox\\firefox.exe");
//             driver = new FirefoxDriver();
//         }
// 
//         jse = (JavascriptExecutor) driver;
//         wait = new WebDriverWait(driver, 10);
//         System.out.println("driver setted up");
//     }
// 
//     public WebDriver getDriver() {
//         return driver;
//     }
// 
//     public void setDriver(WebDriver driver) {
//         this.driver = driver;
//     }
// 
//     public WebDriverPlus get(String url) {
//         driver.get(url);
//         return this;
//     }
// 
//     public String getTitle() {
//         return driver.getTitle();
//     }
// 
//     public WebDriverWait getWait() {
//         return wait;
//     }
// 
//     public JavascriptExecutor getJse() {
//         return jse;
//     }
// 
//     public void randomAction() {
//         Actions actions = new Actions(driver);
//         actions.sendKeys(Keys.PAGE_DOWN).build().perform();
//     }
// 
//     public void quit() {
//         driver.quit();
//     }
// 
// 
// 
//     /*public WebElement findElement(By locator) {
//         if (isElementPresent(locator)) {
//             return driver.findElement(locator);
//         }
//         return null;
//     }
// 
//     public WebElement findElement(By locator, String text) {
//         if (isElementMatch(locator, text)) {
//             return driver.findElement(locator);
//         }
//         return null;
//     }
// 
//     public boolean isElementPresent(By locator) {
//         try {
//             WebElement result = wait.until(ExpectedConditions.presenceOfElementLocated(locator));
//             if (null != result) {
//                 return true;
//             }
//         } catch (Exception e) {
//             e.printStackTrace();
//             return false;
//         }
//         return false;
//     }
// 
//     public boolean isElementMatch(By locator, String text) {
//         return wait.until((ExpectedConditions.textToBePresentInElementLocated(locator, text)));
//     }*/
// }


// Path: src/main/java/com/test/java/webui/project/Page/LoginPage.java
import com.test.java.webui.project.WebDriverPlus;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.How;

package com.test.java.webui.project.Page;


/**
 * Created by beigui on 2016/5/24.
 */
public class LoginPage extends AbstractBasePage {
    public LoginPage(WebDriverPlus webDriverPlus) {
        super(webDriverPlus);
    }

    @FindBy(how = How.ID, using = "userName")
    WebElement username;

    @FindBy(how = How.ID, using = "password")
    WebElement password;

    @FindBy(how = How.ID, using = "submit")
    WebElement submit;

    @FindBy(how = How.ID, using = "usernameHtml02")
    WebElement usernameCheckpoint;

    public void typeUsername(String _username) {
        username.clear();
        username.sendKeys(_username);
    }

    public void typePassword(String _password) {
        password.clear();
        password.sendKeys(_password);
    }

    public boolean isLoginedIn(String text) {
        return textToBePresent(usernameCheckpoint, text);
    }

    public void login() {
        System.out.println("开始登录");
        submit.click();