java - 在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,但问题仍然存在
解决方案
您需要使用这样的现有构造函数:
https://appium.github.io/java-client/io/appium/java_client/android/AndroidDriver.html
你需要使用java.net.URL
而不是com.gargoylesoftware.htmlunit.javascript.host.URL
推荐阅读
- objective-c - 如何重命名sqlite中的列名在目标c中不起作用
- linux - 进程调度:内核如何更新当前运行进程的need_resched标志?
- javascript - 我无法安装 nodemon 而不会出现错误
- python - 让 if/else 在循环两个范围的列表理解中跳出一个循环
- generics - 通用参数在“供应商” lambda 中丢失,但在“可调用”中没有
- java - 获取图像并放入 jframe 的问题
- arrays - 字典保存错误“SwiftValue encodeWithCoder:]: unrecognized selector sent to instance”
- vee-validate - How would I get a different message on each screen?
- python - 如何使用 Python 3 将包含 15,000 条推文的 JSON 文件转换为 CSV
- angular - 在 Angular 中从 Firebase 获取和显示数据