问题一:使用AndroidDriver而非原来的AppiumDriver的原因
AppiumDriver升级到2.0.0版本引发的问题--Cannot instantiate the type AppiumDriver
1. 问题描述和起因
在使用Appium1.7.0及其以下版本的时候,我们可以直接使用如下代码来创建一个AppiumDriver实例进行对安卓设备的操作。
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
但在把Appium包升级到当前最新的2.0.0版本的时候,这段代码会引发如下的一问题
当前的pom.xml相关设置如下:记得把1.7.0改成2.0.0或者是将来更高级版本
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>2.0.0</version>
<del><version>1.7.0</version></del>
</dependency>
2.问题分析
究其原因,发现Appium2.0.0把AppiumDriver这个类改成了抽象函数,所以到导致了这个问题
public <span style="color:#ff0000;">abstract </span>class AppiumDriver extends RemoteWebDriver implements MobileDriver,
ContextAware, Rotatable, FindsByAccessibilityId, LocationContext,
DeviceActionShortcuts, TouchShortcuts, InteractsWithFiles,
InteractsWithApps, ScrollsTo {
private final static ErrorHandler errorHandler = new ErrorHandler(
new ErrorCodesMobile(), true);
private URL remoteAddress;
private RemoteLocationContext locationContext;
private ExecuteMethod executeMethod;
// frequently used command parameters
protected final String KEY_CODE = "keycode";
protected final String PATH = "path";
private final String SETTINGS = "settings";
根据2.0.0的Changelog的第一点:
Changelog
2.0.0
<ul><li><span style="font-family: Arial, Helvetica, sans-serif;">AppiumDriver is now an abstract class, use IOSDriver and AndroidDriver which both extend it. You no longer need to include the PLATFORM_NAME desired capability since it's automatic for each class. Thanks to @TikhomirovSergey for all their work</span></li></ul><span style="font-family:Arial, Helvetica, sans-serif;"><span style="white-space:pre"> </span><span style="color:#3366ff;">AppiumDriver现在变成了一个抽象类,请使用从它继承下来的IOSDriver和AndroidDriver。你不再需要加上PLATFORM_NAME这个capability,因为代码会根据你使用的是IOSDriver或者AndroidDriver来确定究竟是哪个平台。</span>
</span><ul><li><span style="font-family: Arial, Helvetica, sans-serif;">ScrollTo() and ScrollToExact() methods reimplemented</span></li><li><span style="font-family: Arial, Helvetica, sans-serif;">Zoom() and Pinch() are now a little smarter and less likely to fail if you element is near the edge of the screen. Congratulate @BJap on their first PR!</span></li></ul>
3.问题解决
根据问题分析,把代码修改如下,使用AndroidDriver而非原来的AppiumDriver。
public class NoetPadTest {
/**
* Create the test case
*
* @param testName name of the test case
*/
private <span style="color:#ff0000;">AndroidDriver </span>driver;
@Before
public void setUp() throws Exception {
// set up appium
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "apps");
File app = new File(appDir, "NotePad.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName","Android");
//capabilities.setCapability("platformVersion", "4.2");
capabilities.setCapability("platformName", "Android");
//capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.example.android.notepad");
capabilities.setCapability("appActivity", "com.example.android.notepad.NotesList");
//capabilities.setCapability("appActivity", ".NotesList");
driver = new <span style="color:#ff0000;">AndroidDriver</span>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
@After
public void tearDown() throws Exception {
driver.quit();
}
---------------------
原文:https://blog.csdn.net/zhubaitian/article/details/39717889
问题一:使用AndroidDriver而非原来的AppiumDriver的原因的更多相关文章
- Android 非静态内部类导致内存泄漏原因深入剖析
背景 上周发现蘑菇街IM-Android代码里面.一些地方代码编写不当.存在内存泄漏的问题.在和疯紫交流的过程中.发现加深了一些理解,所以决定写一下分析思路,相互学习. 内存泄漏 一个不会被使用的对象 ...
- Mware vCenter Server 识别固态硬盘为(非SSD)是什么原因?
人工定义一下: 用root登录进ESXi控制台:esxcli storage nmp device list #列出储存清单esxcli storage nmp satp rule add -s VM ...
- AppiumDriver升级到2.0.0版本引发的问题--Cannot instantiate the type AppiumDriver
1. 问题描述和起因 在使用Appium1.7.0及其以下版本的时候,我们可以直接使用如下代码来创建一个AppiumDriver实例进行对安卓设备的操作. driver = new AndroidDr ...
- Cannot instantiate the type AppiumDriver,AppiumDriver升级引发的问题
转自:http://blog.csdn.net/zhubaitian/article/details/39717889 1. 问题描述和起因 在使用Appium1.7.0及其以下版本的时候,我们可以直 ...
- MIFARE系列2《非接触卡标准》
根据信号发送和接收方式的不同,ISO/IEC14443-3定义了TYPEA.TYPEB两种卡型.它们的不同主要在于载波的调制深度及二进制数的编码方式.从读写机具向卡传送信号时,二者是通过13.56Mh ...
- JAVA可检测异常和非检测异常
Java的可检测异常和非检测异常泾渭分明.可检测异常经编译器验证,对于声明抛出异常的任何方法,编译器将强制执行处理或声明规则. 非检测异常不遵循处理或声明规则.在产生此类异常时,不一定非要采取任何适当 ...
- C# static 字段初始值设定项无法引用非静态字段、方法或属性
问题:字段或属性的问题字段初始值设定项无法引用非静态字段.方法 下面代码出错的原因,在类中定义的字段为什么不能用? public string text = test(); //提示 字段或属性的问题 ...
- 检索05 --static静态方法 和 非静态方法
C#静态变量使用static 修饰符进行声明,在类被实例化时创建,通过类进行访问不带有 static 修饰符声明的变量称做非静态变量,在对象被实例化时创建,通过对象进行访问一个类的所有实例的同一C#静 ...
- 【Azure 环境】存储在Azure上的文件,使用IE/Edge时自动打开的问题,如何变为下载而非自动打开
问题描述 存储,作为云服务最重要的一部分.当需要从云存储中下载文件时,时常面临一些格式的文件被浏览器自动打开而非下载,那如何来解决这个问题呢? 在Azure中,存储的服务有以下方式: Azure Bl ...
随机推荐
- 记录一下使用element ui使用级联选择器的坑,级联选择器的默认选中
Cascader 级联选择器 使用级联选择器我使用的是默认选中值 下面是我的数据格式,只是形式相同,值不同, 后台的数据是这样的不是ID //级联选择器 <el-cascader :props= ...
- kubectl kubernetes cheatsheet
from : https://cheatsheet.dennyzhang.com/cheatsheet-kubernetes-a4 PDF Link: cheatsheet-kubernetes-A4 ...
- Refactoring open source business models
https://opensource.com/business/16/4/refactoring-open-source-business-models They say you never forg ...
- fullcalendar + qTip2显示事件详情
fullcalendar 是一个很优秀的日历插件.qTip2 是一个强大的提示工具.在讲下面的功能之前,需要对fullcalendar 和 qTip2 有些了解,可直接点击下面贴出的2个地址: ful ...
- 学习Spring-Data-Jpa(八)---定义方法查询
1.查询策略 spring-data一共有三种方法查询策略: QueryLookupStrategy.Key.CREATE,尝试根据方法名进行创建.通用方法是从方法名中删除一组特定的前缀,然后解析该方 ...
- Classification and Decision Trees
分类和决策树(DT). 决策树是预测建模机器学习的一种重要算法. 决策树模型的表示是二叉树.就是算法和数据结构中的二叉树,没什么特别的.每个节点表示一个单独的输入变量(x)和该变量上的左右孩子(假设变 ...
- 学到了林海峰,武沛齐讲的Day49 django
django 终于等到啦,好东西上场了 blog---- 个体应用文件 model.py 数据库文件 views.py 视图文件 admin.py 后台文件,操纵数据库文件 manage.py --- ...
- MySQL 硬链接删除大表
在清理整个大表时,我们推荐使用drop,而非delete.但是如果表实在太大,即使是drop,也需要消耗一定的时间.这时可以利用linux的硬连接来快速删除大表,操作过程如下:有一个大表test,共有 ...
- 洛谷P1081 开车旅行
题目 双向链表+倍增+模拟. \(70pts\): 说白了此题的暴力就是细节较多的模拟题. 我们设离\(i\)城市最近的点的位置为\(B[i]\),第二近的位置为\(A[i]\).设\(A\)或\(B ...
- CF1221F Choose a Square(二维偏序)
由于y=x,我们可以将点对称过来,以便(x,y)(x<y) 考虑选取正方形(a,a,b,b),点集则为\((a\le x\le y\le b)\),相当于二维数点 将点按x降序,y升序排列,线段 ...