-4

I am new to Appium.I have downloaded all the required tools and able to set up environment variable. I try to execute my selenium script in mobile using Appium. But I got an error like below

 enterpackage appiumtest;

import java.net.URL;

import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;

public class Appium {
    static RemoteWebDriver driver1;
    AppiumDriver<MobileElement> driver;


    public static void main(String[] args) {
        try {
            opencalculator();
        }catch(Exception exp) {
            System.out.println(exp.getCause());
            System.out.println(exp.getMessage());
            exp.printStackTrace();


        }
    }
    public static void opencalculator() throws Exception {
        DesiredCapabilities cap = new DesiredCapabilities();
        cap.setCapability("deviceName", "Babar Ali");
        cap.setCapability("UDID", "A6HU4TAQKZYD8L9P");
        cap.setCapability("PLATFORMNAME", "Android");
        cap.setCapability("PLATFORMVERSION", "8.1.0");
        cap.setCapability("appPackage", "com.android.calculator2");
        cap.setCapability("appActivity", "com.android.calculator2.Calculator");
        driver1 = new RemoteWebDriver(new URL("http://0.0.0.0:4723/wd/hub"), cap);


        System.out.println("Application started....");

}
    } 
Soha Mir
  • 3
  • 3

1 Answers1

0

In regard of my comment, a stacktrace is something like:

Exception in thread "main" java.lang.NullPointerException
        at com.example.myproject.Book.getTitle(Book.java:16)
        at com.example.myproject.Author.getBookTitles(Author.java:25)
        at com.example.myproject.Bootstrap.main(Bootstrap.java:14)

Check this question to see how to use it to identify your problems.

Regarding your problem, my guess is that your supplied URL is invalid: http://0.0.0.0:4723/wd/hub whereas 0.0.0.0 isn't a valid IP:

In the Internet Protocol Version 4, the address 0.0.0.0 is a non-routable meta-address used to designate an invalid, unknown or non-applicable target. This address is assigned specific meanings in a number of contexts, such as on clients or on servers

Source: https://en.wikipedia.org/wiki/0.0.0.0

If you want to use your local machine, use localhost or 127.0.0.1 instead.

A 0.0.0.0 usually means that an interface is bound to listen to every IP.

maio290
  • 6,440
  • 1
  • 21
  • 38