您的位置:軟件測(cè)試 > 開源軟件測(cè)試 > 開源功能測(cè)試工具 > Selenium
Selenium測(cè)試框架使用xml作為對(duì)象庫(kù)
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2015/9/14 10:53:03 ] 推薦標(biāo)簽:軟件測(cè)試工具,功能測(cè)試工具

  上次使用的excel作為L(zhǎng)ocator對(duì)象管理,由于excel處理不夠方便,有以下缺點(diǎn):
  不能實(shí)現(xiàn)分page 加載Locator對(duì)象
  不能夠?qū)崿F(xiàn)Locator對(duì)象重名
  文件比較大,讀寫速度沒有xml快
  所以,重新寫了使用dom4j操作xml,使用xml管理Locator對(duì)象,能夠有效解決以上問(wèn)題
  首先,定義Locator文件
  <?xml version="1.0" encoding="UTF-8"?>
  <map>
  <!--locator of page map info -->
  <page pageName="com.dbyl.libarary.pageAction.HomePage">
  <!--Locator lists -->
  <locator type="ByXpath" timeOut="3" value="//div[@class='top-nav-profile']//img[@class='avatar']">profile</locator>
  </page>
  <!--locator of page map info -->
  <page pageName="com.dbyl.libarary.pageAction.LoginPage">
  <!--Locator lists -->
  <locator type="" timeOut="3" value="//input[@name='account' and  not(@autocomplete)]">loginEmailInputBox</locator>
  <locator type="ByXpath" timeOut="3" value="//button[@class='sign-button submit' and text()='登錄']">loginButton</locator>
  <locator type="ByXpath" timeOut="3" value="//div[@class='top-nav-profile']//img[@class='avatar']">profile</locator>
  <locator type="ByXpath" timeOut="3" value="//input[@name='password' and @placeholder='密碼']">loginPasswordInputBox</locator>
  </page>
  </map>
  每一個(gè)Page對(duì)應(yīng)一個(gè)真實(shí)的頁(yè)面,而每一個(gè)page下的Locator對(duì)應(yīng)一個(gè)真實(shí)的頁(yè)面element

  之前定義過(guò)的Locator類如下:
package com.dbyl.libarary.utils;
/**
* This is for element library
*
* @author Young
*
*/
public class Locator {
private String element;
private int waitSec;
/**
* create a enum variable for By
*
* @author Young
*
*/
public enum ByType {
xpath, id, linkText, name, className, cssSelector, partialLinkText, tagName
}
private ByType byType;
public Locator() {
}
/**
* defaut Locator ,use Xpath
*
* @author Young
* @param element
*/
public Locator(String element) {
this.element = element;
this.waitSec = 3;
this.byType = ByType.xpath;
}
public Locator(String element, int waitSec) {
this.waitSec = waitSec;
this.element = element;
this.byType = ByType.xpath;
}
public Locator(String element, int waitSec, ByType byType) {
this.waitSec = waitSec;
this.element = element;
this.byType = byType;
}
public String getElement() {
return element;
}
public int getWaitSec() {
return waitSec;
}
public ByType getBy() {
return byType;
}
public void setBy(ByType byType) {
this.byType = byType;
}
}

上一頁(yè)123下一頁(yè)
軟件測(cè)試工具 | 聯(lián)系我們 | 投訴建議 | 誠(chéng)聘英才 | 申請(qǐng)使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd