ReportFlow:
// click the Grid icon and switch to grid page
public void changeToGrid()
// click the Add/Locate icon in the grid page/or in the controller, and then add investment
public void addInvestmentToGrid(final String fundName, final String ticker, boolean isGridMode)
public void addInvestment(final String fundName, final String ticker, final boolean isGridMode)
// wait for the investment exists in the grid or in the controller
public void waitForInvestmentExistInGrid(final String fundName, final boolean isGridMode)
// click the ColumnManagement icon to enter the ColumnManament popover
public void openColumnSetManagement()
// click the cancel button in the Column Management popover
public void closeColumnSetManagementByCancel()
// remove the Column item in the Column Management popover and then click Done button
public void deleteColumnSet(final String columnName)
// click the posth columnset through clicking the columnset input box in the grid view
public String openColumnset(final int pos)
// click the list input box, then select and click the last investment list in Grid or in Controller
public String openRandomInvestmentList(String testCaseId, boolean isGridMode)
// click the list input box, then select and click the target list in the Grid or in the Controller
public void openInvestmentList(String listName, boolean isGridMode)
// click the checkbox to select it in the save list/column dialog after modifying the list and column
public void selectedCheckBox(WebElement element , boolean checked)
// create new investment list; this method has a wait time after clicking Enter
public void createInvestmentList(final String newName, final boolean isGridMode) // click the Grid icon and switch to grid page
public void changeToGrid(){
WebElement gridIcon = reportPage.getICONGrid(); //get the grid icon
SeleniumUtil.jsClick(driver, gridIcon);
SeleniumUtil.waitForElementVisible(driver, By.cssSelector("div#grid div#primary-header div.grid-header"),"Fail to switch to Grid."); // wait for the grid header to be visible
SeleniumUtil.waitForElementVisible(driver, By.cssSelector("div#grid div#grid-content div.grid-view"),"Fail to switch to Grid."); // wait for the grid content/view to be visible
} // click the Add/Locate icon in the grid page/or in the controller, and then add investment. This method will //also wait for the investment added/existing in the grid or in the controller
public void addInvestmentToGrid(final String fundName, final String ticker, boolean isGridMode) {
if(isGridMode){
reportPage.getAddLocateIconInGridMode().click();
}
else {
reportPage.getAddLocateIcon().click();
}
addInvestment(fundName, ticker, isGridMode);
} public void addInvestment(final String fundName, final String ticker, final boolean isGridMode) {
WebElement inputEl = reportPage.getAddLocateInput();
inputEl.clear();
inputEl.sendKeys(fundName);
final ReportPage page = reportPage;
Function<WebDriver, Boolean> waitFn = new Function<WebDriver, Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
try {
List<WebElement> nameList = page.getAddLocateResultNameList();
List<WebElement> tickerList = page.getAddLocateResultTickerList();
int size = nameList.size();
for(int i = 0; i < size; i++){
WebElement nameEl = nameList.get(i);
WebElement tickerEl = tickerList.get(i);
String nameStr = nameEl.getText().trim();
if(ticker == null){
if(nameStr.contains(fundName.trim())){
nameEl.click();
waitForInvestmentExistInGrid(nameStr, isGridMode);
return true;
}
}
else {
String tickerStr = tickerEl.getText().split("\\|")[0].trim();
if(nameStr.contains(fundName.trim()) && tickerStr.equals(ticker)){
nameEl.click();
waitForInvestmentExistInGrid(nameStr, isGridMode);
return true;
}
}
}
} catch (Exception e) {
}
return false;
}
};
SeleniumUtil.createWait(driver).withMessage("Fail to add investment.").until(waitFn);
} // wait for the investment exists in the grid or in the controller
public void waitForInvestmentExistInGrid(final String fundName, final boolean isGridMode) {
final ReportPage page = reportPage;
Function<WebDriver, Boolean> waitFn = new Function<WebDriver, Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
try {
List<WebElement> list;
if(isGridMode){
list = page.getInvestmentListInGridMode(); // get the investment list in the grid
}
else {
list = page.getInvestmentList(); // get the investment list in the controller
}
for(WebElement el : list){
if(el.getText().contains(fundName)){
return true;
}
}
} catch (Exception e) {
}
return false;
}
};
SeleniumUtil.createWait(driver).withMessage(fundName + " is not in Grid.").until(waitFn);
} // click the ColumnManagement icon to enter the ColumnManament popover
public void openColumnSetManagement(){
WebElement iconColumnManagement = reportPage.getICONColumnManagement();
SeleniumUtil.jsClick(driver, iconColumnManagement);
SeleniumUtil.sleep(2);
} // click the cancel button in the Column Management popover
public void closeColumnSetManagementByCancel(){
WebElement cancleBtn = reportPage.getCancleBtn();
SeleniumUtil.jsClick(driver, cancleBtn);
SeleniumUtil.sleep(2);
} // remove the Column item in the Column Management popover and then click Done button
public void deleteColumnSet(final String columnName) {
openColumnSetManagement(); // enter into ColumnManament popover
SeleniumUtil.sleep(2);
List<WebElement> itemList = reportPage.getColumnManagementItemList();
for(WebElement el : itemList){
WebElement nameEl = el.findElement(By.cssSelector("div.name"));
if(nameEl.getText().equals(columnName)){
el.findElement(By.cssSelector("span.removeMe")).click();
break;
}
}
Function<WebDriver, Boolean> waitFn = new Function<WebDriver, Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
try{
List<String> list = getColumnNamesFromColumnset();
return !list.contains(columnName);
}
catch(Exception e){
}
return false;
}
};
SeleniumUtil.createWait(driver).withMessage("can't delete column:" + columnName).until(waitFn);
reportPage.getBtnDone().click();
} // click the posth columnset through clicking the columnset input box in the grid view
public String openColumnset(final int pos) {
WebElement columnsetEl = reportPage.getTXTColumnset();
columnsetEl.click();
Function<WebDriver, List<WebElement>> waitFn = new Function<WebDriver, List<WebElement>>() {
@Override
public List<WebElement> apply(WebDriver driver) {
try {
List<WebElement> columnsetList = reportPage.getDLGColumnsetList();
if (columnsetList.size() > pos) {
return columnsetList;
}
return null;
} catch (Exception e) {
return null;
}
}
};
List<WebElement> list = SeleniumUtil.createWait(driver).until(waitFn);
String columnsetName = list.get(pos).getText();
list.get(pos).click();
return columnsetName;
} // click the list input box, then select and click the last investment list in Grid or in Controller
public String openRandomInvestmentList(String testCaseId, boolean isGridMode) {
logger.info("start:openRandomInvestmentList"); WebElement nameInputEl;
if(isGridMode){
nameInputEl = reportPage.getListNameDisplayInGridMode();
}
else {
nameInputEl = reportPage.getListNameDisplay();
}
SeleniumUtil.sleep(3);
SeleniumUtil.jsClick(driver, nameInputEl); List<WebElement> list = SeleniumUtil.waitForAllElementsVisible(driver, By.cssSelector("div.popover-list div.entity-row"));
WebElement targetEl = list.get(list.size() -1); //select the last investment list
SeleniumUtil.scrollIntoView(driver, targetEl);
String curListName = targetEl.getAttribute("name");
if(!targetEl.isDisplayed()){
SeleniumUtil.scrollIntoView(driver, targetEl);
}
SeleniumUtil.jsClick(driver, targetEl);
return curListName;
} // click the list input box, then select and click the target list in the Grid or in the Controller,
// you should pass the list name as the target
public void openInvestmentList(String listName, boolean isGridMode){
WebElement nameInputEl;
if(isGridMode){
nameInputEl = reportPage.getListNameInputInGridMode();
}
else {
nameInputEl = reportPage.getListNameInput();
} SeleniumUtil.sleep(3);
if(!SeleniumUtil.isElementVisible(driver, By.cssSelector("div[name='" + listName + "']"))){
if(SeleniumUtil.getBrowserName(driver).equals("firefox")){
SeleniumUtil.waitForPageToLoad(driver);
JavascriptExecutor js = ((JavascriptExecutor) driver);
js.executeScript("$('div.controller-list>input').click();");
}else{
SeleniumUtil.jsClick(driver, nameInputEl);
}
}
WebElement targetEl = SeleniumUtil.waitForElementVisible(driver, By.cssSelector("div[name='" + listName + "']"));
targetEl.click();
} // click the checkbox to select it in the save list/column dialog after modifying the list and column
public void selectedCheckBox(WebElement element , boolean checked){
String classValue = element.getAttribute("class");
if(classValue.contains("selected") && checked){
return;
}
else{
element.click();
}
} // create new investment list; this method has a wait time after clicking Enter
public void createInvestmentList(final String newName, final boolean isGridMode) {
WebElement saveEl = reportPage.getBTNSave();
SeleniumUtil.jsClick(driver, saveEl);
SeleniumUtil.sleep(2);
WebElement nameInputEl;
if(isGridMode){
nameInputEl = reportPage.getListNameInputInGridMode();
}
else {
nameInputEl = reportPage.getListNameInput();
} nameInputEl.clear();
nameInputEl.sendKeys(newName);
nameInputEl.sendKeys(Keys.ENTER); Function<WebDriver, Boolean> waitFn = new Function<WebDriver, Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
try {
WebElement nameInputEl;
if(isGridMode){
nameInputEl = reportPage.getListNameInputInGridMode();
}
else {
nameInputEl = reportPage.getListNameInput();
}
return newName.equals(nameInputEl.getAttribute("value"));
} catch (Exception e) {
return false;
}
}
};
// wait for the list is added successfully
SeleniumUtil.createWait(driver).withMessage("Fail to input name.").until(waitFn);
// wait for the message displayed
SeleniumUtil.waitForElementNotVisible(driver, By.cssSelector("span.message-content"));
} ------------------------------------------------
ReportPage // the input box in the top-left of the grid view
public WebElement getListNameInputInGridMode(); // the list name showing in the input box in the top-left of the grid view
public WebElement getListNameDisplayInGridMode() // the differences between getListNameInputInGridMode and getListNameDisplayInGridMode are:
// getListNameInputInGridMode().value == getListNameDisplayInGridMode()

Automation 的 ReportFlow的更多相关文章

  1. Workload Automation分析及其使用

    Workload Automation介绍 Workload Automation是提供一个在设备上运行各种workload的工具,使用Python编写.WA具有良好的框架结构,方便快捷的扩展.包含几 ...

  2. SQL Server 阻止了对组件 'Ole Automation Procedures' 的 过程'sys.sp_OACreate' 的访问,因为此组件已作为此服务器安全配置的一部分而被关闭。系统管理员可以通过使用 sp_configur

    参见:http://msdn.microsoft.com/zh-cn/library/ms191188(SQL.105).aspx Ole Automation Procedures 选项 [本主题为 ...

  3. first Automation

    //创建一个容器    CEmbWordCntrItem * pItem = NULL;    CEmbWordDoc * pDoc = GetDocument();    pItem = new C ...

  4. SharePoint 2013 中的 PowerPoint Automation Services

    简介                许多大型和小型企业都将其 Microsoft SharePoint Server 库用作 Microsoft PowerPoint 演示文稿的存储库.所有这些企业在 ...

  5. Automation Test in Maya Plugin Development

    现状和问题- 开发插件的功能A的时候随手建立场景, 测试插件的功能A. 测试通过后,测试场景就被丢掉.- 发现插件的功能A有bug时, 修改代码, 然后随手建立场景, 测试bug. 测试通过后,测试场 ...

  6. Study plan for automation test framework

    虽然部门的automation建立起来有两年多,去年项目一直很忙,仅限于应用(e.g 运行脚本测试或者写一些简短的测试脚本),但是一直没有深入研究其组成框架.近期希望抽出时间来做深入学习. 初步计划从 ...

  7. 自动化测试 using System.Windows.Automation;

    frameworke3.0 及以上 using System.Windows.Automation; UIAutomationClient.dll UIAutomationClientsideProv ...

  8. UI Automation Test

    UI Automation test is based on the windows API. U can find the UI Automation MSDN file from http://m ...

  9. Azure Automation (1) 入门

    <Windows Azure Platform 系列文章目录> 通过Azure Automation(自动化),开发人员可以自动完成通常要在云环境中执行的手动.长时间进行.易出错且重复性高 ...

随机推荐

  1. 为OS X开发者准备的15个超棒应用

    几乎所有的开发人员在他们日常的开发工作中都有他们自己不可缺少的工具或实用程序集. 这些工具中的每一个都提供了特定的功能,大多数开发者都已经将他们集成到了其工作流程中. 使用这些工具或实用程序不单单只是 ...

  2. jQuery实现复选框的全选与全不选

    对于复选框的选中checked属性,实在是无力吐槽. 从上图可以看出,当复选框不设置checked属性时,默认没有被选中:其它三种情况,设置checked属性但不设置属性值即置空,或者将checked ...

  3. CCF|碰撞的小球

    import java.util.Scanner; public class Main { public static void main (String[] args) { Scanner scan ...

  4. 微信小程序组件解读和分析:十二、picker滚动选择器

    picker滚动选择器组件说明: picker: 滚动选择器,现支持三种选择器,通过mode属性来区分, 分别是普通选择器(mode = selector),时间选择器(mode = time),日期 ...

  5. iOS---数据离线缓存

    离线缓存 为了用户的体验,不需要每次打开App都加载新数据,或者重新请求数据,因此需要把每次浏览的数据保存起来,当下次打开软件时,首先从沙盒中加载数据:或者当软件未联网时,也只能从沙盒中加载旧数据. ...

  6. Linux修改ssh端口,减少暴力破解

    版本centos7   注意:操作时请勿断开当前的ssh连接,以免发生情况登陆不了.   1.修改的是 /etc/ssh/sshd_config 文件 打开文件之后会发现Port是注释掉的,默认为22 ...

  7. .net mvc 运行监控和错误捕捉

    方法类 /// <summary> /// 运行监控类 /// </summary> [AttributeUsage(AttributeTargets.Class | Attr ...

  8. Farseer.net轻量级ORM开源框架 V1.8版本升级消息

    SHA-1: 775a93cf64df3f49c83cc4f4df346afd2075a68f * 发布V1.8.0修复:Oracle的SQL生成 在没有条件时,缺少Where关键字,导致无法分页修复 ...

  9. 乐视max2 刷入第三方recovery 然后刷入root 包 root

    乐视max2 刷入第三方recovery 然后刷入root 包 root 第三方recovery:为奇兔 刷入root 包 https://share.weiyun.com/ddcdd5ea83956 ...

  10. (转)淘淘商城系列——分布式文件系统FastDFS

    http://blog.csdn.net/yerenyuan_pku/article/details/72801777 商品添加的实现,包括商品的类目选择,即商品属于哪个分类?还包括图片上传,对于图片 ...