1.验证页面上的车贷计算器算的结果是否与需求中给的公式结果一致。

页面图片:

代码如下(简单实现,需要优化):

package com.test;

import java.math.BigDecimal;

import org.junit.Assert;
import org.openqa.selenium.By;
import org.testng.Reporter;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test; import com.core.base.MidConvert; /**
* @author QiaoJiafei
* @version 创建时间:2015年12月4日 下午2:23:36
* 类说明
*/
@Listeners({com.core.base.BaseListener.class})
public class Testlaiyongche extends MidConvert{
String url = "http://172.16.30.243:8888/offical/home.action";
double car_shoujia = 5000000.36;//车辆售价
double car_other = 1000.55;//其他费
double car_sfbl = 40.21;//首付比例
int car_zuqi = 24;//车辆租期 @BeforeClass
public void before() {
super.initDriver();
//http://172.16.30.243:8888/offical/home.action
dr.get(url);
lc = cm.getLocator("linkText", "业务指南");
cm.click(lc);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
lc = cm.getLocator("className", "marginbottom20");
dr.findElement(By.className("marginbottom20")).findElements(By.tagName("button")).get(3).click();
}
@AfterClass
public void after() {
super.tearDown();
}
@Test
public void testSuiXin() {
testmain("极速融","1",car_zuqi);//1-新车,2-二手车,3-LCV,4-微面
testmain("极速融","2",car_zuqi);
testmain("极速融","3",car_zuqi);
} @Test
public void testJs() {
testmain("随心融","1",car_zuqi);
}
@Test
public void testKx() {
testmain("开心融","4",car_zuqi);
} public void testmain(String pd, String ct, int carz) {
String product = pd;//融资产品
String cartype = ct;//车辆类型
//车辆类型:
lc = cm.getLocator("id", "carType");
cm.select(lc, ct); //融资产品:
lc = cm.getLocator("id", "product");
cm.select(lc, product); //车辆售价:
lc = cm.getLocator("id", "carPrice");
cm.type(lc, String.valueOf(car_shoujia)); //其他费用:
lc = cm.getLocator("id", "otherPrice");
cm.type(lc, String.valueOf(car_other)); //车辆租期:
lc = cm.getLocator("id", "tenancy");
cm.select(lc, String.valueOf(car_zuqi)); //首付比例
lc = cm.getLocator("xpath", "/html/body/section[2]/div/div/div/div/div[2]/div[4]/div[1]/table[2]/tbody/tr[6]/td[2]/input");
cm.type(lc, String.valueOf(car_sfbl)); //保证金比例
String s = dr.findElement(By.id("bail")).getText();
double bzj = car_shoujia*Integer.parseInt(s)/100; lc = cm.getLocator("id", "calculation");
cm.click(lc);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
double re_sfje = car_shoujia*car_sfbl/100 +bzj;//首付金额
double re_rzje = car_shoujia - re_sfje + car_other;//融资金额 double nll = 0;//月利率
if(product.equals("随心融")) {
nll = 0.17680;
}else if(product.equals("极速融")) {
if(cartype.equals("1")) {
nll = 0.17680;
}else if (cartype.equals("2")) {
nll = 0.18680;
}else if(cartype.equals("3")) {
nll = 0.19680;
}
}else if (product.equals("随意融")) {
nll = 0.18680;
}else if(product.equals("开心融")) {
nll = 0.25970;
}else if (product.equals("爱心融")) {
nll = 0.19680;
}
double yll = nll / 12;
double a = 1+yll;
double b = car_zuqi;
double temp = Math.pow(a, b); double re_yg = (re_rzje*yll*temp)/(temp-1);//月供金额
//BigDecimal bd1 = new BigDecimal(re_yg);
//double f1 = bd1.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); double re_rg = re_yg/30;//日供
//BigDecimal bd2 = new BigDecimal(re_rg);
//double f2 = bd2.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue(); String ac_rzje = dr.findElement(By.id("financingAm")).getText();
String ac_sfje = dr.findElement(By.id("firstPay")).getText();
String ac_yg = dr.findElement(By.id("monthlyPay")).getText();
String ac_rg = dr.findElement(By.id("dayPay")).getText();
//System.out.println(ac_rzje+"------------"); Assert.assertEquals(new java.text.DecimalFormat("#.##").format(re_rzje), ac_rzje);
Assert.assertEquals(new java.text.DecimalFormat("#.##").format(re_sfje), ac_sfje);
Assert.assertEquals(new java.text.DecimalFormat("#.##").format(re_yg), ac_yg);
Assert.assertEquals(new java.text.DecimalFormat("#.##").format(re_rg), ac_rg); Reporter.log(pd+","+ct+",测试通过");
}
}

selenium验证车贷计算器算法的更多相关文章

  1. IOS OC 计算器算法(不考虑优先级)

    个人见解:为还在计算器算法方面迷惑的同学一个数据处理解决方案:定义一个可变数组array,一个可变字符串str,使字符通过[array addObject:str];方法添加到可变数组,每当触发运算符 ...

  2. Python开发——利用正则表达式实现计算器算法

    Python开发--利用正则表达式实现计算器算法 (1)不使用eval()等系统自带的计算方法 (2)实现四则混合运算.括号优先级解析 思路: 1.字符串预处理,将所有空格去除 2.判断是否存在括号运 ...

  3. iOS 收款计算器算法

    一个收款计算器算法,从之前高仿有赞Demo里面抽离的一个界面 demo 在这里 https://github.com/L-vinCent/calculView_function 显示计算记录 不能连续 ...

  4. 基于COCO数据集验证的目标检测算法天梯排行榜

    基于COCO数据集验证的目标检测算法天梯排行榜 AP50 Rank Model box AP AP50 Paper Code Result Year Tags 1 SwinV2-G (HTC++) 6 ...

  5. hdoj 2063 过山车【匈牙利算法+邻接矩阵or邻接表】

    过山车 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

  6. Selenium 验证picklist是可被正确选中且是有序的(动态数组赋值)

    原代码: <select id="edit-submitted-im-interesting-in" class="form-select required&quo ...

  7. hdu 2063 过山车【匈牙利算法】(经典)

    <题目链接> RPG girls今天和大家一起去游乐场玩,终于可以坐上梦寐以求的过山车了.可是,过山车的每一排只有两个座位,而且还有条不成文的规矩,就是每个女生必须找个个男生做partne ...

  8. hdu-2063-过山车(匈牙利算法)

    过山车 Problem Description RPG girls今天和大家一起去游乐场玩,终于可以坐上梦寐以求的过山车了.可是,过山车的每一排只有两个座位,而且还有条不成文的规矩,就是每个女生必须找 ...

  9. HDU 2063.过山车-Hungary(匈牙利算法)

    过山车 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

随机推荐

  1. java ftp

    FTPUtil import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import jav ...

  2. CentOS常用指令

    创建文件: 如touch a.txt 创建文件夹: mkdir -p 文件夹名,当文件夹不存在时候,创建这个文件夹 文件重命名: 把文件text.php得命名为index.php,可以是rename ...

  3. MAC 隐藏文件的显示

    显示 defaults write com.apple.finder AppleShowAllFiles -bool true 隐藏 defaults write com.apple.finder A ...

  4. Orchard中文版源码下载

    本版本基于Orchard1.7.2修改: 新增Bootstrap主题 新增中文语言包 增加了对Sqlite.Orchard数据库的支持 优化工程,减少临时符号生成,增加工程效率 和一些BUG的修正 默 ...

  5. online judge(ACM) 的设计与分析 (有c#demo)

    ACM.OJ,算法在线判题系统. 帮朋友完成毕业设计而写的,软件环境windows系统,语言是C# winform(因为我不熟悉asp.net,现在暂用winform写的demo). 看了下其他相关论 ...

  6. CSS布局——横向两列布局

    1.固定两栏布局,使用float,注意对紧邻元素清除浮动影响.IE6在使用float布局同时设置横行margin的情况下会有双边距BUG,解决方案是加入_display:inline 代码如下: &l ...

  7. 一些arcgis符号库干货

    分享一些arcgis符号库干货,自己也可以参考网上的教程自己做,但尽量要符合标准规范. 下面是一些符号示例(并不一定是官方标准的): 土地利用总体规划图 水土保持图 1:5万土地利用现状 1:1万地形 ...

  8. 【读书笔记】iOS-NSData

    Cocoa为我们提供了NSData类,该类包装了大量字节,你可以获得数据的长度和指向字节起始位置的指针,因为NSData是一个对象,适用于常规的内存管理行为.因此,如果将数据块传递给一个函数或方法,可 ...

  9. Java从零开始学四十三(DOM4j解析XML)

    一.创建XML // 建立XML public static void gernatorXML() { // 创建Document对象 Document doc = DocumentHelper.cr ...

  10. iOS之 kamailio-4.3.4sip服务器搭建-mac

    如要转载请注明出处http://www.cnblogs.com/chengxiaoyu/p/5006352.html 1.安装MySQL 去http://www.mysql.com/下载最新版本的My ...