appium 3-31603调试分析方法
1.Appium Log
清晰记录了所有的请求和结果
@Test
public void testDebug() throws InterruptedException,IOException{
MobileElement tiaoguo = (MobileElement) driver.findElementByXPath("//*[@text='跳过']");
FileUtils.copyFile(new File("tiaoguo.png"),tiaoguo.getScreenshotAs(OutputType.FILE));
Thread.sleep(15000);
}
IDE执行结果:提示方法没有实现

appium日志

通过log中可以获取更多的信息,如
在screenshot方法执行时,有URL链接,加上IP和port,访问就可以获取到更多信息。
127.0.0.1:4723/wd/hub/session/92fe82c7-02ac-4fca-a8da-eca08027f985/element/1/screenshot
可以看到/appium/node_modules/appium-base-driver/lib/basedriver/driver.js:249:13中方法未实现
{"value":{"error":"unknown method","message":"Method has not yet been implemented","stacktrace":"NotYetImplementedError: Method has not yet been implemented\n at AndroidDriver.executeCommand$ (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/driver.js:249:13)\n at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)\n at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)\n at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)\n at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)\n at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)\n at Promise (<anonymous>)\n at F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)\n at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)\n at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)\n at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)\n at AndroidDriver.executeCommand (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/build/lib/basedriver/driver.js:271:34)\n at AppiumDriver.executeCommand$ (/usr/local/lib/node_modules/appium/lib/appium.js:377:50)\n at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)\n at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)\n at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)\n at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)\n at <anonymous>\n at process._tickCallback (internal/process/next_tick.js:169:7)"}}
cat -n /usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/driver.js

2.getPageSource
界面的完整dom结构.xml文件
封装locate方法,加入异常处理,将获取的节点信息在编辑器中打开,检索控件。
public WebElement locate(String locate){
try {
if (locate.matches("\\/\\/.*")) {
return driver.findElementByXPath(locate);
} else {
return driver.findElementById(locate);
}
}catch (org.openqa.selenium.NoSuchElementException EX){
System.out.println(locate);
System.out.println(driver.getPageSource());
return null;//没有返回值,代码会报错
}
}
@Test
public void TestDriver() throws InterruptedException{
Thread.sleep(5000);
//driver.findElementByXPath("//*[@text=\"允许\"]").click();
locate("//*[@text=\"允许\"]").click();
Thread.sleep(2000);
}
因为locate中返回的null,click找不到会因找不到控件报ava.lang.NullPointerException错误


3.脚本内调试
利用xpath获取所有匹配的元素 driver.findElementByXpath("//*")
public WebElement locate(String locate) throws InterruptedException{
try {
if (locate.matches("\\/\\/.*")) {
return driver.findElementByXPath(locate);
} else {
return driver.findElementById(locate);
}
}catch (org.openqa.selenium.NoSuchElementException EX){
List<AndroidElement> lists = driver.findElementsByXPath("//*");
for(AndroidElement e:lists){
System.out.print("tag: "+e.getTagName()+"\t");
System.out.print("text: "+e.getText()+"\t");
System.out.println("id: "+e.getAttribute("resourceId"));
//System.out.println(e.getAttribute("contentDesc"));该属性有误,content-desc也不可用
Thread.sleep(500);
}
return null;
}
}
FAQ
1.tagName打印null
@Test
public void TestDriver() throws InterruptedException{
Thread.sleep(5000);
List<AndroidElement> lists66 = driver.findElementsByXPath("//*");
for(AndroidElement e66:lists66){
System.out.print("tag: "+e66.getTagName()+"\t");
System.out.print("text: "+e66.getText()+"\t");
System.out.println("id: "+e66.getAttribute("resourceId"));
Thread.sleep(500);
}
Thread.sleep(20000);
}

appium 3-31603调试分析方法的更多相关文章
- Appium调试分析方法
在使用appium做自动化测试的时候,发现用例报错,如何排查原因? 查看appium日志 appium日志大概是分为以下部分 culr命令调试 在理解appium协议的基础上,可以直接用shell发送 ...
- Appium Server 源码分析之启动运行Express http服务器
通过上一个系列Appium Android Bootstrap源码分析我们了解到了appium在安卓目标机器上是如何通过bootstrap这个服务来接收appium从pc端发送过来的命令,并最终使用u ...
- Appium Android Bootstrap源代码分析之启动执行
通过前面的两篇文章<Appium Android Bootstrap源代码分析之控件AndroidElement>和<Appium Android Bootstrap源代码分析之命令 ...
- Appium Server源码分析之作为Bootstrap客户端
Appium Server拥有两个主要的功能: 它是个http服务器,它专门接收从客户端通过基于http的REST协议发送过来的命令 他是bootstrap客户端:它接收到客户端的命令后,需要想办法把 ...
- iOS 苹果官方 Crash文件分析方法 (iOS系统Crash文件分析方法)
时间2013-08-20 12:49:20 GoWhich原文 http://www.gowhich.com/blog/view/id/343 苹果官方 Crash文件分析方法 (iOS系统Cras ...
- IDA 调试 Android 方法及简单的脱壳实现
IDA 调试 Android 方法及简单的脱壳实现 标签: android原创逆向调试dalvik 2016-05-24 14:24 9286人阅读 评论(3) 收藏 举报 分类: 原创(25) An ...
- WinDbg调试分析 net站点 CPU100%问题
WinDbg调试分析 asp.net站点 CPU100%问题 公司为了节省成本,最近有一批服务器降了配置,CPU从8核降到了2核.本身是小站点,访问量也不高,CPU总是会飙到100%而且可以一直持续几 ...
- 基于appium的常用元素定位方法
一.元素定位工具 app应用的元素使用的是控件定位,不同于web网页,web网页定位元素通常使用的是F12工具,那么在app当中我们则要借助其它的工具来辅助定位. 1.uiautomatorviewe ...
- [Android]第一个cm调试分析
0x00:写在前面 一直想入门Android安全,当时是极客大挑战出题的时候,被cx表哥甩锅强行去学了点android的开发,之后慢慢接触,感觉还是挺有意思的.cx表哥说先从逆向分析入门吧,之后可以 ...
随机推荐
- 关于python课程的想法和建议。
第一次听说python是在刚结束与世隔绝的高中生活之后,当时的网络上铺天遍地都是人工智能和机器学习,于是便知道了python这门编程语言.我是光电信息科学与工程专业的学生,这个专业的学生必须要懂计算机 ...
- L1-010 比较大小
本题要求将输入的任意3个整数从小到大输出. 输入格式: 输入在一行中给出3个整数,其间以空格分隔. 输出格式: 在一行中将3个整数从小到大输出,其间以“->”相连. 输入样例: 4 2 8 输出 ...
- DevExpress v17.2新版亮点—DevExtreme篇(二)
用户界面套包DevExpress DevExtreme v17.2终于正式发布,本站将以连载的形式为大家介绍各版本新增内容.本文将介绍了DevExtreme v17.2 的New Color Sche ...
- apache的日志access_log分析
正常日志格式:客户端地址 访问者的标识 访问者的验证名字 请求的时间 请求类型 请求的HTTP代码 发送给客户端的字节数 当网站出问题时分析日志,第一步一般都不会是看访问日志.但是也不能忽视它,在 ...
- [转]数据库更新(Update语句)查询
2011-03-27 10:40:11| 分类: Database |举报|字号 订阅原文出自:http://blog.csdn.net/ylnjust02/archive/2005/12/10/54 ...
- CS231n 斯坦福深度视觉识别课 学习笔记(完结)
课程地址 第1章 CS231n课程介绍 ---1.1 计算机视觉概述 这门课的主要内容是计算机视觉.它是一门需要涉及很多其他科目知识的学科. 视觉数据占据了互联网的绝大多数,但是它们很难利用. --- ...
- OK335xS CAN device register and deiver match hacking
/************************************************************************* * OK335xS CAN device regi ...
- shell 脚本实战笔记(3)--集群机器的时间同步设置
背景: 有些分布式服务(比如HBase服务), 依赖于系统时间戳, 如果集群各个节点, 系统时间不一致, 导致服务出现诡异的情况. 解决方案: 那如何同步集群各个节点之间的时间? 采用NTP(Netw ...
- CodeForces - 1097D:Makoto and a Blackboard (积性)
Makoto has a big blackboard with a positive integer n written on it. He will perform the following a ...
- CTF-练习平台-Misc之 这么多数据包
十一.这么多数据包 下载文件后解压,用wireshark打开CTF.pcapng,发现有很多包,快速浏览后发现前面都是攻击机(192.168.116.138)在向目标机(192.168.116.159 ...