运行 Appium 测试时出现以下错误
Exception in thread "main" org.openqa.selenium.remote.SessionNotFoundException: A session is either terminated or not started (Original error: Command failed: 'adb' is not recognized as an internal or external command,
operable program or batch file.
) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 13.51 seconds
Build info: version: '2.30.0', revision: 'dc1ef9c', time: '2013-02-19 00:15:27'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_41'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.new Instance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:187)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:151)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)
at tests.AppiumTest.main(AppiumTest.java:29)
随后的步骤-
1.ANDROID_HOME env设置为sdk路径(E:\softwares\android\adt-bundle-windows-x86-20130729\sdk) 2.使用Appium.exe启动Appium服务器 3.Selenium独立服务器启动
代码:-
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("app-package", "com.android.example.spinner");
caps.setCapability("browserName", "");
caps.setCapability("device", "Android");
caps.setCapability("app-activity",
"com.android.example.spinner.SpinnerActivity");
caps.setCapability("takesScreenshot", true);
caps.setCapability("version", "4.3");
caps.setCapability("device ID", "5554");
caps.setCapability("app",
"E:\\eclipse\\SpinnerActivity\\bin\\SpinnerActivity.apk");
RemoteWebDriver driver = new RemoteWebDriver(new URL(
"http://localhost:4723/wd/hub/"), caps);