标签:org https gets 首页 UI open 页面 click import
package www.gui.huohu.pom; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.interactions.Actions; public class DengLuPage { WebDriver driver; public static void main(String[] args) { // TODO Auto-generated method stub DengLuPage dl= new DengLuPage(); dl.init(); dl.doLogin("admin", "admin", true); } private void init() { // TODO Auto-generated method stub System.setProperty("webdriver.firefox.bin", "D:\\FireFox__37\\firefox.exe"); this.driver = new FirefoxDriver();// 启动火狐浏览器 this.driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);// 元素等待时间 this.driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);// 页面加载时间 this.driver.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS);// ajax请求 this.driver.manage().window().maximize(); // this.driver.get("https://www.baidu.com/");// 在浏览器中打开该网址 this.driver.get("http://localhost/Agileone/"); } private WebElement getUsernameInputbox() { // TODO Auto-generated method stub return this.driver.findElement(By.id("username")); } private WebElement getPasswordInputbox() { // TODO Auto-generated method stub return this.driver.findElement(By.id("password")); } private WebElement getSaveloginInputbox() { // TODO Auto-generated method stub return this.driver.findElement(By.id("savelogin")); } private WebElement getLoginButton() { // TODO Auto-generated method stub return this.driver.findElement(By.id("login")); } private void doLogin(String username, String password, Boolean isSaveLogin) { // TODO Auto-generated method stub this.getUsernameInputbox().sendKeys(username); this.getPasswordInputbox().sendKeys(password); if(isSaveLogin){ this.getSaveloginInputbox().click(); } this.getLoginButton().click(); } }
标签:org https gets 首页 UI open 页面 click import
原文地址:http://www.cnblogs.com/wujianbo123/p/7667869.html