appium java实现计算器测试+问题解决

本文介绍了使用Appium和Java进行计算器自动化测试的步骤,包括查看设备信息、获取应用详情、使用UIAutomatorViewer获取屏幕截图等。在编码和运行过程中遇到了Java类库兼容性问题,如NoClassDefFoundError、IncompatibleClassChangeError和UnsupportedClassVersionError,并逐一给出了解决方案,涉及Junit版本、Hamcrest库、Java源代码级别和JDK版本匹配等问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、查看设备名,win+R,运行输入框内输入cmd:输入adb devices ,查看设备名(需记下);

2、查看android应用包名、activity的方法:https://www.cnblogs.com/paulwinflo/p/4739734.html;

1):没有apk,应用已经安装到手机或虚拟机中:

logcat命令:输入 adb logcat -c 清除logcat内容;

启动logcat: 输入adb logcat ActivityManager:I*:s;

启动要查看的应用

2):dumpsys命令

启动要查看的程序;

命令行输入: adb shell dumpsys window w|findstr \/| findstr name=;

2、打开sdk->tools->uiautomatorviewer.bat,获取手机页面截屏。

3、编码:java;

4、启动appium,运行代码;

遇到的问题:

1、使用junit运行代码的时候,出现报错: Java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing;

原因:使用的junit jar包版本为4.12,从4.11版本开始,该jar包里面已经不包含hamcrest jar包了。

解决方法:1:降低junit jar包版本;2:下载hamcrest jar 包

2、实现类报错:

java.lang.IncompatibleClassChangeError: Implementing class;

解决方法:将原来的jar包全部移除后,再重新导入jar包/移除不需要的jar包。

3、The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files。

原因&解决方法,在Stack Overflow上找到的: Java 8 supports default methods in interfaces. And in JDK 8 a lot of old interfaces now have new default methods. For example, now in CharSequence we have chars and codePoints methods.

If source level of your project is lower than 1.8, then compiler doesn't allow you to use default methods in interfaces. So it cannot compile classes that directly on indirectly depend on this interfaces.

If I get your problem right, then you have two solutions. First solution is to rollback to JDK 7, then you will use old CharSequence interface without default methods. Second solution is to set source level of your project to 1.8, then your compiler will not complain about default methods in interfaces。

4、java.lang.UnsupportedClassVersionError:Unsupported major.minor version51(由于上一个问题,我已经把jdk降到1.6了,但是,运行的时候报的这个错误,是因为jdk版本不支持。 The error regarding the unsupported major.minor version is because during compile time you are using a higher JDK and a lower JDK during runtime.

把jdk升到1.7的时候有报错52了,没办法只能将jdk变回1.8,但是前面的第三的问题又出现了

解决方法:重新安装一个版本较高的eclipse;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值