无法实例化 AppiumDriver 类型 [英] Cannot instantiate the type AppiumDriver

查看:30
本文介绍了无法实例化 AppiumDriver 类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目构建路径中添加了以下 jars:

I have added following jars in my projects build path:

  1. java-client-2.0.0 来自 http://appium.io/downloads.html>> Appium 客户端库 >> Java
  2. selenium-java-2.43.1
  3. selenium-java-2.43.1-srcs
  4. selenium-server-standalone-2.43.1
    这是我的代码:

  1. java-client-2.0.0 from http://appium.io/downloads.html >> Appium Client libraries >> Java
  2. selenium-java-2.43.1
  3. selenium-java-2.43.1-srcs
  4. selenium-server-standalone-2.43.1
    and here's my code:

public class SampleApp{

WebDriver dr;

@Test
public void testApp() throws MalformedURLException, InterruptedException {
    String apkpath = "D:\\apkdump\\sampleapp.apk";
    File app = new File (apkpath);
    DesiredCapabilities capabilities= new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.BROWSER_NAME,"");
    capabilities.setCapability("deviceName","TestADB18");
    capabilities.setCapability("platformName","Android");
    capabilities.setCapability("app",app.getAbsolutePath());
    capabilities.setCapability("appPackage", "com.test");
    capabilities.setCapability("appActivity", "com.sampleapp.Main");
    dr = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
    dr.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

}


}

我在 new AppiumDriver 下方看到红线,表示 无法实例化 AppiumDriver 类型.现在,如果删除所有 selenium jars,错误就会消失,但我无法使用 webdriver 解决错误.

jar 之间的冲突是什么?

我在这里看到了类似的问题,但是可以运行代码并且得到 Null指针异常 但在我的情况下,我什至无法运行它,它在保存代码时运行.其次,答案已发布而未使用 AppiumDriver

I am getting red line below new AppiumDriver which says that Cannot instantiate the type AppiumDriver. Now if remove all selenium jars the error disappears but then I can't resolve errors with webdriver.

What is the conflict between jars?

I saw similar question here but that could run the code and was getting Null pointer exception but in my case I cant even run it, it is giving run on saving the code. Secondly the answer has been posted without using AppiumDriver

推荐答案

可以通过将 Appium Client(请参阅我问题中的第 1 步)从 latest 降级到 java- 来修复此错误-客户端-1.5.0.您可以将其余的罐子保持最新.

Appium Client 的降级版本可以从这里下载http://mvnrepository.com/artifact/io.appium/java-client/1.5.0

This error can be fixed by downgrading the Appium Client(see step 1 in my question) from latest to java-client-1.5.0. You can keep rest of the jars to latest.

Downgraded version of Appium Client can be downloaded from here http://mvnrepository.com/artifact/io.appium/java-client/1.5.0

这篇关于无法实例化 AppiumDriver 类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆