我已经尝试在eclipse IDE中多次运行此代码,但是每次出现以下错误。我真的不知道哪里出了问题以及如何解决。请有人帮忙。我已经在IDE中编写了以下代码。
File f = new File("src"); File fs = new File(f,"ApiDemos-debug.apk");
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Demo");
cap.setCapability(MobileCapabilityType.APP, fs.getAbsolutePath());
System.setProperty("webdriver.http.factory", "apache");
AndroidDriver<AndroidElement> driver = new AndroidDriver<AndroidElement>(new URL("http://127.0.0.1:4723/wd/hub"),cap);
错误消息:
Exception in thread "main" org.openqa.selenium.WebDriverException: It is impossible to create a new session because 'createSession' which takes HttpClient, InputStream and long was not found or it is not accessible
答案 0 :(得分:0)
确保您使用的是最新的Appium服务器1.9.1和Java客户端6.1.0。
已安装最新的Android SDK和ADB。
卸载Appium设置并从您的设备解锁应用。
在设备上启用了USB调试。
您所需的功能应至少如下:
示例所需功能:
final DesiredCapabilities caps = DesiredCapabilities.android ();
caps.setCapability (CapabilityType.PLATFORM_NAME, "Android");
caps.setCapability (MobileCapabilityType.PLATFORM_VERSION, "7.0");
caps.setCapability (MobileCapabilityType.DEVICE_NAME, "your device name");
caps.setCapability (MobileCapabilityType.APP, "/your/app/path/app.apk");
AndroidDriver <AndroidElement> driver = new AndroidDriver <> (new URL ("http://127.0.0.1:4723/wd/hub"), caps);