2
votes

Here i provide the steps i followed. In Eclipse, Selenium server, selenium-java, testng6.8 jar files added in referenced libraries Started the Appium Server. Server started I got following error: Console:

Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: The following desired capabilities are required, but were not provided: strong text*platformName) (WARNING: The server did not provide any stacktrace information) strong text Command duration or timeout: 182 milliseconds Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:30' System info: host: 'TestingServer', ip: '192.168.1.150', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_17' Driver info: 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) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:126) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:153) at com.gorillalogic.monkeytalk.demo.Demo.setup(Demo.java:37) at com.gorillalogic.monkeytalk.demo.Demo.main(Demo.java:71)

In appium Server:

Starting Node Server info: Welcome to Appium v1.2.0 (REV e53f49c706a25242e66d36685c268b599cc18da5) debug: Non-default server args: {"app":"D:\Apk\com.gorillalogic.monkeytalk.demo1.apk","address":"127.0.0.1","logNoColors":true,"androidPackage":"com.gorillalogic.monkeytalk.demo1","androidActivity":"com.gorillalogic.monkeytalk.demo1.RootActivity","avd":"TestMani","platformName":"Android","platformVersion":"19","automationName":"Appium"} info: Appium REST http interface listener started on 127.0.0.1:4723 info: LogLevel: debug info: --> POST /wd/hub/session {"desiredCapabilities":{"automationName":"Appium","platform":"WINDOWS","app":"D:\Apk\com.gorillalogic.monkeytalk.demo1.apk","deviceName":"Android Emulator","browserName":"","appActivity":"com.gorillalogic.monkeytalk.demo1.RootActivity","appPackage":"com.gorillalogic.monkeytalk.demo1","version":"4.4"}} debug: Appium request initiated at /wd/hub/session info: <-- POST /wd/hub/session 500 10.015 ms - 290 debug: Request received with params: {"desiredCapabilities":{"automationName":"Appium","platform":"WINDOWS","app":"D:\Apk\com.gorillalogic.monkeytalk.demo1.apk","deviceName":"Android Emulator","browserName":"","appActivity":"com.gorillalogic.monkeytalk.demo1.RootActivity","appPackage":"com.gorillalogic.monkeytalk.demo1","version":"4.4"}} error: The following desired capabilities are required, but were not provided: platformName debug: Got configuration error, not starting session debug: Cleaning up appium session error: Failed to start an Appium session, err was: Error: The following desired capabilities are required, but were not provided: platformName debug: Error: The following desired capabilities are required, but were not provided: platformName at Capabilities.checkValidity (E:\Appium\node_modules\appium\lib\server\capabilities.js:120:13) at Appium.configure (E:\Appium\node_modules\appium\lib\appium.js:256:35) at Appium.start (E:\Appium\node_modules\appium\lib\appium.js:100:10) at Object.exports.createSession [as handle] (E:\Appium\node_modules\appium\lib\server\controller.js:159:16) at next_layer (E:\Appium\node_modules\appium\node_modules\express\lib\router\route.js:103:13) at Route.dispatch (E:\Appium\node_modules\appium\node_modules\express\lib\router\route.js:107:5) at E:\Appium\node_modules\appium\node_modules\express\lib\router\index.js:213:24 at Function.proto.process_params (E:\Appium\node_modules\appium\node_modules\express\lib\router\index.js:286:12) at next (E:\Appium\node_modules\appium\node_modules\express\lib\router\index.js:207:19) at next (E:\Appium\node_modules\appium\node_modules\express\lib\router\index.js:182:38) debug: Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: The following desired capabilities are required, but were not provided: platformName)","origValue":"The following desired capabilities are required, but were not provided: platformName"},"sessionId":null}

Please anyone help me...am trying this on last 2 weeks

2
can we have an accepted answer to this please.Naman

2 Answers

4
votes

You need to set the platformName in your desired capabilities list:

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

if you are using Android.

Here's an example with all of them:

    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);

This link will have some more examples:

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

-1
votes

You are missing platformName capability

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