Appium 1.2.0.1服务器在运行脚本时显示错误

时间:2014-09-29 09:27:46

标签: appium

  

这里我提供了我遵循的步骤。   在Eclipse中,   在引用的库中添加了Selenium服务器,selenium-java,testng6.8 jar文件   启动了Appium Server。服务器启动了   我收到以下错误:   控制台:

     

线程中的异常" main" org.openqa.selenium.SessionNotCreatedException:无法创建新会话。 (原始错误:需要以下所需功能,但未提供:强文本* platformName)(警告:服务器未提供任何堆栈跟踪信息)   strong text命令持续时间或超时:182毫秒   构建信息:版本:' 2.42.2',修订版:' 6a6995d',时间:' 2014-06-03 17:42:30'   系统信息:主机:' TestingServer',ip:' 192.168.1.150',os.name:' Windows 7',os.arch:' x86',os.version:' 6.1',java.version:' 1.6.0_17'   驱动程序信息:org.openqa.selenium.remote.RemoteWebDriver       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)       at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)       at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)       at java.lang.reflect.Constructor.newInstance(Unknown Source)       在org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)       在org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)       在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)       在org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)       在org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:126)       在org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:153)       在com.gorillalogic.monkeytalk.demo.Demo.setup(Demo.java:37)       在com.gorillalogic.monkeytalk.demo.Demo.main(Demo.java:71)

     

在appium Server中:

     

启动节点服务器   info:欢迎来到Appium v​​1.2.0(REV e53f49c706a25242e66d36685c268b599cc18da5)   debug:非默认服务器args:{" app":" D:\ Apk \ com.gorillalogic.monkeytalk.demo1.apk","地址":& #34; 127.0.0.1"" logNoColors":真," androidPackage":" com.gorillalogic.monkeytalk.demo1"" androidActivity":" com.gorillalogic.monkeytalk.demo1.RootActivity"" AVD":" TestMani"" platformName":& #34; Android和#34;" platformVersion":" 19"" automationName":" Appium"}   info:Appium REST http接口监听器在127.0.0.1:4723上启动   info:LogLevel:debug   信息: - > POST / wd / hub / session {" desiredCapabilities":{" automationName":" Appium"," platform":" WINDOWS& #34;," app":" D:\ Apk \ com.gorillalogic.monkeytalk.demo1.apk"," deviceName":" Android Emulator& #34;" browserName":""" appActivity":" com.gorillalogic.monkeytalk.demo1.RootActivity"&# 34; appPackage":" com.gorillalogic.monkeytalk.demo1""版本":" 4.4"}}   debug:在/ wd / hub / session启动的Appium请求   info:< - POST / wd / hub / session 500 10.015 ms - 290   debug:使用params收到的请求:{" desiredCapabilities":{" automationName":" Appium"," platform":" WINDOWS& #34;," app":" D:\ Apk \ com.gorillalogic.monkeytalk.demo1.apk"," deviceName":" Android Emulator& #34;" browserName":""" appActivity":" com.gorillalogic.monkeytalk.demo1.RootActivity"&# 34; appPackage":" com.gorillalogic.monkeytalk.demo1""版本":" 4.4"}}   错误:需要以下所需功能,但未提供:platformName   debug:收到配置错误,没有启动会话   debug:清理appium会话   错误:无法启动Appium会话,错误是:错误:需要以下所需功能,但未提供:platformName   debug:错误:需要以下所需功能,但未提供:platformName       在Capabilities.checkValidity(E:\ Appium \ node_modules \ appium \ lib \ server \ capabilities.js:120:13)       在Appium.configure(E:\ Appium \ node_modules \ appium \ lib \ appium.js:256:35)       在Appium.start(E:\ Appium \ node_modules \ appium \ lib \ appium.js:100:10)       在Object.exports.createSession [作为句柄](E:\ Appium \ node_modules \ appium \ lib \ server \ controller.js:159:16)       在next_layer(E:\ Appium \ node_modules \ appium \ node_modules \ express \ lib \ router \ route.js:103:13)       在Route.dispatch(E:\ Appium \ node_modules \ appium \ node_modules \ express \ lib \ router \ route.js:107:5)       在E:\ Appium \ node_modules \ appium \ node_modules \ express \ lib \ router \ index.js:213:24       在Function.proto.process_params(E:\ Appium \ node_modules \ appium \ node_modules \ express \ lib \ router \ index.js:286:12)       在下一个(E:\ Appium \ node_modules \ appium \ node_modules \ express \ lib \ router \ index.js:207:19)       在下一个(E:\ Appium \ node_modules \ appium \ node_modules \ express \ lib \ router \ index.js:182:38)   debug:响应客户端并出现错误:{" status":33," value":{" message":"无法创建新会话。 (原始错误:需要以下所需功能,但未提供:platformName)"," origValue":"需要以下所需功能,但未提供:platformName&# 34;}"的sessionId":空}

请有人帮助我......我在过去两周内尝试过这个问题

2 个答案:

答案 0 :(得分:4)

您需要在所需的功能列表中设置platformName:

capabilities.setCapability("platformName", "Android");

如果您使用的是Android。

以下是所有这些示例:

    File classpathRoot = new File(System.getProperty("user.dir"));
    File appDir = new File(classpathRoot, "../../../apps/ContactManager");
    File app = new File(appDir, "ContactManager.apk");
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
    capabilities.setCapability("platformName", "Android");
    capabilities.setCapability("deviceName","Android Emulator");
    capabilities.setCapability("platformVersion", "4.4");
    capabilities.setCapability("app", app.getAbsolutePath());
    capabilities.setCapability("appPackage", "com.example.android.contactmanager");
    capabilities.setCapability("appActivity", ".ContactManager");
    driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

此链接将包含更多示例:

https://github.com/appium/sample-code/tree/master/sample-code/examples/java/junit

答案 1 :(得分:-1)

您缺少platformName功能

capabilities.setCapability("platformName", "Android");