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

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

问题描述

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

I have added following jars in my projects build path:

    来自 http://appium.io/downloads.html
  1. java-client-2.0.0 >> 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下显示红线,表示Cannot instantiate the type AppiumDriver.现在,如果删除所有selenium jars,错误消失了,但是我无法使用webdriver解决错误.

罐子之间有什么冲突?

我在此处看到了类似的问题,但这可以运行代码并得到Null pointer exception,但是就我而言,我什至无法运行它,这使代码可以保存.其次,答案已发布而未使用 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)从最新降级为java-client-1.5.0来解决此错误.您可以将其余的罐子保持最新状态.

可以从此处 http://mvnrepository下载Appium Client的降级版本. 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天全站免登陆