zoukankan      html  css  js  c++  java
  • Webdriver的设计模式:Page Object(页面模型)

    设计思想:面向对象,将单个页面所有可能用到元素封装到一个page类中,并提供一些常用的方法,其属性就代表页面元素,普通方法代表对元素所做的操作

    以博客园的登录页面为例:

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    public class BlogLogin {

    //登陆账号元素
    WebElement account;

    //登陆密码元素
    WebElement password

    //登录按钮元素
    WebElement loginBtn;

    //构造方法,用于初始化页面对象及其页面元素
    public BlogLogin(WebDriver driver) {

    //定位账号输入框
    account=driver.findElement(By.id("input1"));

    //定位到密码输入框
    password=driver.findElement(By.id("input2"));

    //定位到登录按钮
    loginBtn=driver.findElement(By.id("signin"));
    }

    //提供一个登录的方法,只需要提供用户名,密码即可登录
    public void Login(String username,String userpassword){
    account.sendKeys(username);
    password.sendKeys(userpassword);
    loginBtn.click();
    }
    }

  • 相关阅读:
    boost::ptree;boost::xml_parser
    boost::array
    boost::timer
    boost::gregorian日期
    boost::algorithm/string.hpp
    boost::lexical_cast
    QT::绘图
    QT::透明
    centos上freefilesync与定时任务
    centos上安装freefilesync工具配置说明
  • 原文地址:https://www.cnblogs.com/zw520ly/p/5879935.html
Copyright © 2011-2022 走看看