简体   繁体   English

Appium 网络驱动程序

[英]Appium Webdriver

I am new to Appium.I have downloaded all the required tools and able to set up environment variable.我是 Appium 的新手。我已经下载了所有必需的工具并能够设置环境变量。 I try to execute my selenium script in mobile using Appium.我尝试使用 Appium 在移动设备中执行我的 selenium 脚本。 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....");

}
    } 

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:关于您的问题,我的猜测是您提供的 URL 无效:http: http://0.0.0.0:4723/wd/hub : http://0.0.0.0:4723/wd/hub0.0.0.0不是有效 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.在 Internet 协议版本 4 中,地址 0.0.0.0 是不可路由的元地址,用于指定无效、未知或不适用的目标。 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来源: 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.如果要使用本地计算机,请改用localhost127.0.0.1

A 0.0.0.0 usually means that an interface is bound to listen to every IP. A 0.0.0.0通常意味着接口绑定到侦听每个 IP。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM