码迷,mamicode.com
首页 > 其他好文 > 详细

POM思想__多个页面时进行的处理

时间:2017-10-14 18:41:46      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:tco   key   row   ges   click   any   ini   log   str   

一、代码如下

package www.gui.huohu.pom;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class GongnengTest {
	static WebDriver driver= null;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		GongnengTest g= new GongnengTest();
		//g.dengluGongneng();
		g.xuqiutianXinzengGongneng();

	}
	
	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 void dengluGongneng() {
		// TODO Auto-generated method stub
		this.init();
		new DengLuPage(this.driver).doLogin("admin", "admin", true);
		if(this.driver.getPageSource().contains("蜗牛学院")) {
			System.out.println("登录测试__:成功");
		} else{
			System.out.println("登录测试__:失败");
		}
	}
	
	private void xuqiutianXinzengGongneng() {
		// TODO Auto-generated method stub
		this.init();
		new DengLuPage(this.driver).doLogin("admin", "admin", true);
		new XuqiutianMokuai(this.driver).doXinzeng();

	}

}

 

 

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;

public class XuqiutianMokuai {
	WebDriver driver= null;
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}
	
	
	
	public XuqiutianMokuai(WebDriver driver) {
		// TODO Auto-generated constructor stub
		this.driver= driver;
	}
	
	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 getXuqiutianLianjie() {
		// TODO Auto-generated method stub
		return this.driver.findElement(By.partialLinkText("需求提案"));
	}

	private void getBianhaoInputbox() {
		// TODO Auto-generated method stub
		
	}
	
	private void getChuangjianzheInputbox() {
		// TODO Auto-generated method stub

	}
	
	private void getLeixingSelectbox() {
		// TODO Auto-generated method stub

	}
	
	private void getZhongyaoxingSelectbox() {
		// TODO Auto-generated method stub

	}
	
	private WebElement getBiaotiInputbox() {
		// TODO Auto-generated method stub
		return this.driver.findElement(By.id("headline"));
	}
	
	private WebElement getContentButton() {
		// TODO Auto-generated method stub
		return this.driver.findElement(By.className("ke-common-icon"));
	}
	
	private WebElement getContentInputBox() {
		// TODO Auto-generated method stub
		return this.driver.findElement(By.className("ke-textarea"));
	}
	
	private void getChulijieguoInputbox() {
		// TODO Auto-generated method stub

	}
	
	private WebElement getXinzengButton() {
		// TODO Auto-generated method stub
		return this.driver.findElement(By.id("add"));

	}
	
	private void getShousuoButton() {
		// TODO Auto-generated method stub

	}
	
	private void getChongzhiButton() {
		// TODO Auto-generated method stub

	}
	
	private void getBianjiButton() {
		// TODO Auto-generated method stub

	}
	
	private void getShanchuButton() {
		// TODO Auto-generated method stub

	}
	
	private void getXinjianyonghugushiButton() {
		// TODO Auto-generated method stub

	}
	
	private void getBianhaoOnerow() {
		// TODO Auto-generated method stub

	}
	
	private void getBiaotiOnerow() {
		// TODO Auto-generated method stub

	}
	
	public void doXinzeng() {
		// TODO Auto-generated method stub
		this.getXuqiutianLianjie().click();
		this.getBiaotiInputbox().sendKeys("wujianbo");
		this.getContentButton().click();
		this.getContentInputBox().sendKeys("wujianbo");
		this.getXinzengButton().click();
	}
}

 

POM思想__多个页面时进行的处理

标签:tco   key   row   ges   click   any   ini   log   str   

原文地址:http://www.cnblogs.com/wujianbo123/p/7667877.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!