0

New to Java here! Trying to automate a sample app and I'm getting the above error. The appium and selenium-java versions are compatible. Tried adding another dependency selenium-remote-driver but the issue still persists.

<dependencies>
    <!-- https://mvnrepository.com/artifact/io.appium/java-client -->
    <dependency>
        <groupId>io.appium</groupId>
        <artifactId>java-client</artifactId>
        <version>7.3.0</version>
     </dependency>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.141.59</version>
    </dependency>
  </dependencies>

Can someone please help?

public class base {
    public static void main(String[] args) throws MalformedURLException {
        
        File appDir =new File("src");
        File app =new File(appDir, "ApiDemos-debug.apk"); 
        DesiredCapabilities cap=new DesiredCapabilities();
        cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Pixel 4-Test"); 
        cap.setCapability(MobileCapabilityType.APP, app.getAbsolutePath() ); 
        cap.setCapability(MobileCapabilityType.AUTOMATION_NAME, "uiautomator2");
        AndroidDriver<AndroidElement> driver = new AndroidDriver<AndroidElement>(new URL("http://127.0.0.1:4723/wd/hub"), cap); 
}
Nikitaaa
  • 11
  • 2

3 Answers3

0

Try to Invalidate cache and restart if you are using IntelliJ.

TDev
  • 75
  • 1
  • 10
  • Tried, it's still the same, Also I noticed that when i comment the last line AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap); there aren't any errors...Any reason why? – Nikitaaa Jul 09 '22 at 12:58
0

Check the path of the Class that you are trying to run.

If you are running via any xml file, check the path of the class there. It might look something like -

<class name="tests.path.for.your.class.file">
indayush
  • 55
  • 2
  • 9
0

Are you sure that:

 File appDir =new File("src");

Is the correct path to the application source?