当我为以下代码运行Appium测试时

时间:2015-07-27 10:09:27

标签: appium

AndroidDriver driver;

@Test
public void setUp() throws MalformedURLException{

     //Set up desired capabilities and pass the Android app-activity and app-package to Appium

   DesiredCapabilities capabilities = new DesiredCapabilities();
   /*capabilities.setCapability("BROWSER_NAME", "Android");*/
   capabilities.setCapability("platformVersion", "5.1");
   capabilities.setCapability("deviceName","G4");
   capabilities.setCapability("platformName","Android");
   capabilities.setCapability("appPackage", "StatusBar"); // This is package name of your app (you can get it from apk info app
   capabilities.setCapability("appActivity", "com.android.calculator2/.Calculator t126"); // This is Launcher activity of your app (you can get it from apk info app)
   //Create AndroidDriver instance and connect to the Appium server.
   //It will launch the Calculator App in Android Device using the configurations specified in Desired Capabilities
   driver = new AndroidDriver(new URL("http://10.97.52.83:4723/wd/hub"), capabilities);

}

获得以下错误

org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: 'java -version' failed. Error: Command failed: 'java' 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: 242 milliseconds
Build info: version: '2.45.0', revision: '32a636c', time: '2015-03-05 22:01:35'
System info: host: 'ingglw016025a', ip: '10.97.52.83', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_51'

1 个答案:

答案 0 :(得分:0)

此错误表示您的appium服务器未运行。只是尝试杀死服务器并重新启动它。这应该解决了这个问题。