Cannot instantiate the type AppiumDriver,AppiumDriver升级引发的问题
转自:http://blog.csdn.net/zhubaitian/article/details/39717889
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.问题解决
- 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();
- }
Cannot instantiate the type AppiumDriver,AppiumDriver升级引发的问题的更多相关文章
- Cannot instantiate the type HttpClient问题
看自己动手写爬虫,没想到一上来就跪了. 里面提到用的jar包是apache的http客户端开源项目---HttpClient 就去官网下载了一个版本4.3 当按书上代码敲时 HttpClient ht ...
- Cannot instantiate the type List<Integer>
在使用java.util.List; 的时候,把语句写成了: List<Integer> arr = new List<Integer>(); 导致错误: Cannot ins ...
- Cannot instantiate the type Map
今天在使用Map中犯了个低级错误,记录一下: 打算使用map为一个视频List观看记录的统计标识,key为vid,value默认为false,当该key已经统计,标识value为true,初始实例化M ...
- AppiumDriver升级到2.0.0版本引发的问题--Cannot instantiate the type AppiumDriver
1. 问题描述和起因 在使用Appium1.7.0及其以下版本的时候,我们可以直接使用如下代码来创建一个AppiumDriver实例进行对安卓设备的操作. driver = new AndroidDr ...
- Cannot instantiate the type AppiumDriver
I have added following jars in my projects build path: java-client-2.0.0 from http://appium.io/downl ...
- SQLSERVER 2012之AlwaysOn -- 一次硬件升级引发的问题
这是上周遇到的一个案例:对已有的硬件进行升级而引发的问题,期间还触发了一个比较严重的BUG,可谓多灾多难:不过值得庆幸的是,在一连串连锁问题出现的时候,并没有出现人工操作失误(这往往是在处理故障中风险 ...
- input的type等于mage标签引发的页面提交!
主要原因是使用了<input type="image",而且放在了<form中. <input type="image"标签类似<inp ...
- 工作学习2-gcc升级引发的崩溃
分享一下调查gcc 8.0下,函数漏写返回值崩溃问题,调查记录. 现在新的硬件,基本操作系统都是redhat 8.0,升级后测试时,发现了一个崩溃问题,记录一下. ================== ...
- 定制化JDK升级引发的离奇事件
1.背景 由于Oracle对外宣称Oracle JDK停止免费用于商用.公司法务部门评估之后担心后续会惹上光司,于是就开始了JDK升级-将所有服务Oracle修改为OpenJDK.上周开始微服务JDK ...
随机推荐
- pat 1029 1029. 旧键盘(20)
旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现.现在给出应该输入的一段文字.以及实际被输入的文字,请你列出肯定坏掉的那些键. 输入格式: 输入在2行中分别给出应该输入的文字.以及实际 ...
- 奇奇怪怪的冒泡排序 TOJ 2014: Scramble Sort
粘贴两个特别简单的冒泡排序 2014: Scramble Sort Description In this problem you will be given a series of lists co ...
- 多重部分和 poj1742
Description People in Silverland use coins.They have coins of value A1,A2,A3...An Silverland dollar. ...
- 在LoadRunner向远程Linux/Unix执行命令行并收集性能数据
前面介绍过在LoadRunner的Java协议实现“使用SSH连接Linux”,当然连接之后的故事由你主导. 今天要讲的,是一个非Java版本.是对“在LoadRunner中执行命令行程序之:pope ...
- iOS NSLog各种打印
%@ 对象 %d,%i 整型 (%i的老写法) %hd 短整型 %ld , %lld 长整型 %u 无符整型 %f 浮点型和double型 %0.2f 精度浮点数,只保留两位小数 %x: 为32 ...
- 【Luogu】P3708Koishi的数字游戏(数论)
题目链接 考虑f(i)=i%1+i%2+i%3+.....+i%n f(i+1)=(i+1)%1+(i+1)%2+......+(i+1)%n 其中不是i+1的因数的部分在f(i+1)的地方都加了1. ...
- 【Luogu】P1578奶牛浴场(DP,枚举)
题目链接 枚举极大子矩形.详情请见本题题解:I_AM_HelloWord 代码如下 #include<cstdio> #include<cctype> #include< ...
- poj 3525 求凸包的最大内切圆
Most Distant Point from the Sea Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 3640 ...
- Mongodb_分片集群模式
前面介绍的副本集模式实现了数据库高可用. 但是还是存在的问题是: 所有的从节点都是从主节点全面拷贝,这样数据量过大时,从节点压力大.还有就是海量数据时存在硬件瓶颈, 毕竟每一个机器的存储量总是有限的. ...
- Day 12 shell语法及程序若干
1. 现归纳一下shell中的运算符: +:对两个变量做加法. -:对两个变量做减法. *:对两个变量做乘法. /:对两个变量做除法. **:对两个变量做幂运算. ...