Unable to create instance of AppiumDriver

I added the following jars in the project building path:

  • java-client-2.0.0 from http://appium.io/downloads.html > Appium Client Libraries β†’ Java
  • selenium Java-2.43.1
  • Selenium Java-2.43.1-SRCS
  • Selenium Server Stand-Alone-2.43.1
    and here is 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); } } 

    I get a red line below new AppiumDriver which says Cannot instantiate the type AppiumDriver . Now, if you delete all selenium jars , the error will disappear, but then I can not resolve the errors using webdriver.

    What is the conflict between banks?

    I saw a similar question here , but it could run the code and received a Null pointer exception , but in my case I can’t even run it, it gives a start when the code is saved. Secondly, a response was sent without using AppiumDriver

+6
source share
4 answers

This error can be fixed by lowering the value of the Appium Client (see step 1 in my question) from the latter to java-client-1.5.0 . You can save the remains of cans to the last.

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

+1
source

You do not need to lower or nothing. There is a design change in Java Client version 2.0.0, as they are mentioned on the site :

AppiumDriver is now an abstract class using IOSDriver and AndroidDriver that extend it.

So, just change the driver line as follows:

 dr = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities); 

Hope this helps ...

+22
source
 WebDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),getDesiredCapabilities("192.21.168.56:5555")); 

use this. and import:

 import io.appium.java_client.AppiumDriver; import io.appium.java_client.android.AndroidDriver; 
0
source

dr = new AppiumDriver (new URL (" http://127.0.0.1:4723/wd/hub ", features);

correct url to be set

0
source

Source: https://habr.com/ru/post/977651/


All Articles