python埋点⾃动化_appuim埋点⾃动化测试分享1、appium+testng+mysql
⽤例组装:xml-⽂件-⽅法-case集合/case;
F:\appium\AutoTestDemo-master\log
F:\appium\AutoTestDemo-master\target\allure-results
2、⽤例⾃动检查设计
⾃动化操作⽬的检查;
⾃动化操作后的埋点结果检查;
3、脚本执⾏检查的两种⽅法:
Assert.assertEquals(true,aftercount == beforecount+1|| aftercount == beforecount-1,
"wishlist_add"+" test fail,Not equals:");
/*categories_sort_pricefromlowtohigh_click排序点击*/
for(intj =0;j <2;j++) {
Thread.sleep(2000);
List sortItems = driver.findElementsByXPath("//android.widget.TextView[@text='Price: Low to High']");
if(sortItems.isEmpty()) {
j =0;
logger.info("wait2s");
}else{
logger.info("categories_sort_pricefromlowtohigh_click"+" test success!");
break;
}
}
4、⼩技巧
4.1、碰到返回结果不知道多久返回时,巧⽤for循环等待
//循环等待转圈圈消失
for(intj=0;j <2;j++) {
Thread.sleep(1000);
List sortItems = driver.findElementsByXPath("//android.widget.TextView[@text='Ship from Saudi']");
if(sortItems.isEmpty()) {
j =0;
}else{
break;
}
}
/*categories_sort_pricefromlowtohigh_click*/
flag = false;
for(int i=0 ; i<11 ; i++){
Event features_click = new Event();
features_click.setEventkey("categories_sort_pricefromlowtohigh_click");
features_click.setPagename("Categories");
events.add(features_click);
Map features_clickAllrs= BIQuery2.queryEvent(events,eventBefore);
Set features_clickGet = features_clickAllrs.keySet();
Assert.assertEquals(i<10,true,"###TestCase### "+"categories_sort_pricefromlowtohigh_click"+" Query bi fail"); for (Integer test:features_clickGet) {
if(test<0) {
Thread.sleep(10000);
logger.info("wait 10s");
break;
}else {
logger.info("###TestCase### "+(test).getEventkey()+" Query bi success!");
flag =true;
}
}
if(flag){
break;
}
}
4.2、巧⽤循环调整控件所在位置
intwidth = driver.manage().window().getSize().width;
intheight = driver.manage().window().getSize().height;
Thread.sleep(2000);
//当前屏幕轮询获取Recommended
for(inti =0;i <2;i++) {
Thread.sleep(1000);
List appiumItems = driver.findElementsByXPath("//android.widget.TextView[@text='Recommended']");
if(appiumItems.isEmpty()) {
driver.swipe(width /2,height *6/8,width/2,height /8,1000);
i =0;
}else{
i =3;
}
}
//轮询定位Recommended位于屏幕上⽅
for(inti =0;i <2;i++) {
WebElement recommendBtn =driver.findElementByAndroidUIAutomator("new UiSelector().text(\"Recommended\")"); intstartY = Location().y;
logger.info(" "+startY);
Thread.sleep(1000);
if(startY < height/12){
i=3;
}else{
driver.swipe(width /2,height *2/12,width/2,height /12,1000);
i=0;
}
}
4.3、调试报错⽇志有针对性的排查问题及打印⽇志
1、想调试打印class内所有的控件
//⾸次打开关闭freegift弹框
List textFieldsList = driver.findElementsByClassName("android.widget.ImageView");
for(inti=0;i
System.out.(i).getText());
//(i).click();
mysql下载app}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论