# 网点可用性
业务流程:
- 通过接口获取所有城市、网点信息,包括名字、是否银行等(此处采取自定义方式展现)
- 将重复逻辑封装,自动实现业务逻辑
- 通过OCR文字识别,得出网点是否为银行
例子中展示:
- 封装重复逻辑
- Error信息自定义,在子用例结束时抛出
- 结果判定,如此用例判断网点是否为银行的正确性
- TypeScript
- Python
import octopus from "jd-octopus"
describe("网点用例", function () {
var c = octopus("10.222.50.39:8080")
var {device,info,img,text,point,swipe,sleep} = octopus()
let uuids = ["ca829b6"]
var err = ""
it("获取控制设备",()=>{
device.bindDevices(uuids)
sleep(1000)
})
function slideDown(x:number){
point.clickByPixel(540,450) // 下拉
sleep(2000)
for(var i=0;i<x;i++){
point.clickByPixel(540,1902) // 下滑一个城市
sleep(1000)
}
point.clickByPixel(950,1350) // 确定
sleep(3000)
}
function qiehuan(x:number,y:number,shangquan:string[],city:string){
for (var j =0;j<shangquan.length;j++){
if(j>12){
y= 2164
for(var i=0;i<j-12;i++){
swipe.verticalRoll(0.0625) // 滑动一个网点
sleep(2000)
}
}
point.clickByPixel(x,y)
sleep(3000)
try {
text("扫码开玩").existByOCR()
} catch (error) {
err += "\n"+city+"--"+shangquan[j]+" 是银行" // 自定义err
}
sleep(2000)
point.clickByPixel(50,270) // 切换
sleep(3000)
y+=124
}
}
it("进入趣玩街",()=>{
img("./test/网点可用性/img/趣玩街.png").click()
sleep(10000)
img("./test/网点可用性/img/允许.png").click()
sleep(2000)
})
it("执行切换商城",()=>{
point.clickByPixel(50,270) // 切换
sleep(2000)
var cityList= ["上海","佛山","北京","厦门","广州","西安","郑州","重庆"]
for(var i= 0;i<cityList.length;i++){
var x = 200
var y = 676
var list
if(i ==0){
list =["世纪汇广场","世博源广场","百联中环购物广场","静安大悦城","爱琴海微站","世茂广场","爱琴海B1"]
}
if(i==1){
list =["九珑璧支行","季华支行","澜普支行","世纪康城支行","盛南新都支行","影萌路支行","锦华支行","绿景三路支行","大福南支路","普君新城支路","广佛路支行","同济支行","同福路支行","东方水岸支行","榴子支行","莲华支行","厚辉支行","江湾支行","威尔斯广场支行","佛平路支行"]
}
if(i==2){
list =["京东6号楼四层C1区09","京东商超移动点位5区"]
}
if(i==3){
list =["厦门国际会议展览中心"]
}
if(i==4){
list =["中国银行广州合景支行"]
}
if(i==5){
list =["西安曲江大悦城"]
}
if(i==6){
list =["郑州农商银行老鸦陈支部"]
}
if(i==7){
list =["京东电器超级体验店"]
}
slideDown(i)
qiehuan(x,y,list,cityList[i])
}
if(err != ''){
throw new Error(err)
}
})
it("退出趣玩街", ()=>{
device.runKeyCode(4)
sleep(2000)
device.runKeyCode(3)
sleep(2000)
})
})
← 网络请求、异步错误捕获 不断执行程序 →