首页 > 解决方案 > 在eclipse中找不到带有Appium的构造函数AndroidDriver

问题描述

有错误的代码:

package TestCase;

import java.net.MalformedURLException;
import java.net.URI;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import com.gargoylesoftware.htmlunit.javascript.host.URL;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.remote.MobilePlatform;

public class TestWebBrowser {
    //AppiumDriver driver = new IOSDriver();
    public static AndroidDriver driver;

    public static void main(String[] args) throws MalformedURLException {           
        DesiredCapabilities capabilities = new DesiredCapabilities();   
        driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);  
    }
}

消息错误是:

  • 构造函数 URL(string) 未定义
  • 构造函数 AndroidDriver(URL, DesiredCapabilities) 未定义
  • AndroidDriver 是原始类型

我尝试了不同版本的 java-client,但问题仍然存在

标签: javaandroidappiumappium-android

解决方案


您需要使用这样的现有构造函数:

https://appium.github.io/java-client/io/appium/java_client/android/AndroidDriver.html

你需要使用java.net.URL而不是com.gargoylesoftware.htmlunit.javascript.host.URL


推荐阅读