POM思想__多个页面时进行的处理
Posted 18513757531
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了POM思想__多个页面时进行的处理相关的知识,希望对你有一定的参考价值。
一、代码如下
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思想__多个页面时进行的处理的主要内容,如果未能解决你的问题,请参考以下文章
是否有在单个活动中处理多个片段的 Android 设计模式?
PCL异常处理:pcl 1.8.13rdpartyoostincludeoost-1_64oost ypeofmsvc ypeof_impl.hpp(125): error(代码片段