selenium验证车贷计算器算法
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验证车贷计算器算法的更多相关文章
- IOS OC 计算器算法(不考虑优先级)
个人见解:为还在计算器算法方面迷惑的同学一个数据处理解决方案:定义一个可变数组array,一个可变字符串str,使字符通过[array addObject:str];方法添加到可变数组,每当触发运算符 ...
- Python开发——利用正则表达式实现计算器算法
Python开发--利用正则表达式实现计算器算法 (1)不使用eval()等系统自带的计算方法 (2)实现四则混合运算.括号优先级解析 思路: 1.字符串预处理,将所有空格去除 2.判断是否存在括号运 ...
- iOS 收款计算器算法
一个收款计算器算法,从之前高仿有赞Demo里面抽离的一个界面 demo 在这里 https://github.com/L-vinCent/calculView_function 显示计算记录 不能连续 ...
- 基于COCO数据集验证的目标检测算法天梯排行榜
基于COCO数据集验证的目标检测算法天梯排行榜 AP50 Rank Model box AP AP50 Paper Code Result Year Tags 1 SwinV2-G (HTC++) 6 ...
- hdoj 2063 过山车【匈牙利算法+邻接矩阵or邻接表】
过山车 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...
- Selenium 验证picklist是可被正确选中且是有序的(动态数组赋值)
原代码: <select id="edit-submitted-im-interesting-in" class="form-select required&quo ...
- hdu 2063 过山车【匈牙利算法】(经典)
<题目链接> RPG girls今天和大家一起去游乐场玩,终于可以坐上梦寐以求的过山车了.可是,过山车的每一排只有两个座位,而且还有条不成文的规矩,就是每个女生必须找个个男生做partne ...
- hdu-2063-过山车(匈牙利算法)
过山车 Problem Description RPG girls今天和大家一起去游乐场玩,终于可以坐上梦寐以求的过山车了.可是,过山车的每一排只有两个座位,而且还有条不成文的规矩,就是每个女生必须找 ...
- HDU 2063.过山车-Hungary(匈牙利算法)
过山车 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...
随机推荐
- Free Slideshow, Gallery And Lightboxes Scripts
http://bootstraphelpers.codeplex.com/SourceControl/list/changesets https://github.com/gordon-matt/Bo ...
- sql 去重
;WITH CETAS (SELECT *, ROW_NUMBER() OVER (PARTITION BY SearchTask_PKID ORDER BY SearchTask_PKID) Row ...
- [moka同学笔记]yii表单dropdownlist样式
<?= $form->field($modelUser,'name') ?> <div class="form-group field-community-mobil ...
- 使scp不用输入密码
使scp不用输入密码 有些时候,我们在复制/移动文件 到另一台机器时会用到scp,因为它比较安全.但如果每次都要输入密码,就比较烦了,尤其是在script里.不过,ssh有另一种用密钥对来验证的方式. ...
- pygame for python3.3
pygame的更新慢的令人发指,我最初使用的python是3.4版本的,无何奈何pygame不支持3.4,甚至官网只有3.2版本的.我于是将各种版本试了一遍,出现各种问题,同时我比较钟爱3.x版本,最 ...
- mysql内存消耗分析
最近有些生产服务器老是mysql内存不停得往上涨,开发人员和维护反馈,用了不少的临时表,问题时常线上发生,测试又一直比较难重现. 经观察mysql内存的os占用趋势,发现从8:40开始,mysql内存 ...
- 胖AP(1602i)与苹果设备之间的问题总结
问题现象: 苹果设备(5GHz)连接不稳定,表现为时断时续,或者加入无线的时候一直加入不进去. 有些2.4GHz设备会在几个AP之间相互跳. 分析: 1. 先说苹果设备,它既支持2.4G 也支持5G, ...
- JS之跨域
今天学了跨域,迫不及待想跟大家分享!不妥之处希望大家指正. 首先来明确一下"跨域"这个概念. 跨域指的是,到外域去取数据.那什么是"外域"呢?我们先来了解同域. ...
- RecyclerView和ScrollView嵌套使用
我们的recyclerView有多个layoutmanager,通过重写layoutmanager的方法就可以让recyclerView和ScrollView嵌套了.但是请注意,如果recyclerV ...
- android 判断屏幕是否亮着
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); boolean screen = p ...