I am unable to get Appium to start an Android session and did not find anything related to the error message I am getting when I searched online.
When I run my test Appium dumps this log:
[debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [null,null,[{"desiredCapabilities":{"platformVersion":"7.0","appiumVersion":"1.11.1","automationName":"UiAutomator2","platformName":"Android","deviceName":"ZX1G22GRHD","applicationName":"Absolute"}},{"requiredCapabilities":{}}]]
[debug] [BaseDriver] Event 'newSessionRequested' logged at 1552607433945 (16:50:33 GMT-0700 (Pacific Daylight Time))
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1552607433945 (16:50:33 GMT-0700 (Pacific Daylight Time))
[debug] [W3C] Encountered internal error running command: Error: Either JSONWP or W3C capabilities should be provided
[debug] [W3C] at parseCapsForInnerDriver (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/lib/utils.js:58:14)
[debug] [W3C] at AppiumDriver.createSession (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/lib/appium.js:262:26)
[debug] [W3C] at AppiumDriver.executeCommand (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/driver.js:301:19)
[debug] [W3C] at AppiumDriver.executeCommand (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/lib/appium.js:429:26)
[debug] [W3C] at asyncHandler (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:352:34)
[debug] [W3C] at app.(anonymous function) (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:489:15)
[debug] [W3C] at Layer.handle [as handle_request] (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/express/lib/router/layer.js:95:5)
[debug] [W3C] at next (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/express/lib/router/route.js:137:13)
[debug] [W3C] at Route.dispatch (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/express/lib/router/route.js:112:3)
[debug] [W3C] at Layer.handle [as handle_request] (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/express/lib/router/layer.js:95:5)
[debug] [W3C] at /Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/express/lib/router/index.js:281:22
[debug] [W3C] at Function.process_params (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/express/lib/router/index.js:335:12)
[debug] [W3C] at next (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/express/lib/router/index.js:275:10)
[debug] [W3C] at logger (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/morgan/index.js:144:5)
[debug] [W3C] at Layer.handle [as handle_request] (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/express/lib/router/layer.js:95:5)
[debug] [W3C] at trim_prefix (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/express/lib/router/index.js:317:13)
[debug] [W3C] at /Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/express/lib/router/index.js:284:7
[debug] [W3C] at Function.process_params (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/express/lib/router/index.js:335:12)
[debug] [W3C] at next (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/express/lib/router/index.js:275:10)
[debug] [W3C] at /Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/body-parser/lib/read.js:130:5
[debug] [W3C] at invokeCallback (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/raw-body/index.js:224:16)
[debug] [W3C] at done (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/raw-body/index.js:213:7)
[debug] [W3C] at IncomingMessage.onEnd (/Users/davethomas/.nvm/versions/node/v10.15.0/lib/node_modules/appium/node_modules/raw-body/index.js:273:7)
[debug] [W3C] at IncomingMessage.emit (events.js:182:13)
[debug] [W3C] at endReadableNT (_stream_readable.js:1094:12)
[debug] [W3C] at process._tickCallback (internal/process/next_tick.js:63:19)
[HTTP] <-- POST /wd/hub/session 500 5 ms - 738
[HTTP]
My test:
public class AndroidTestCaseExample {
public AndroidDriver driver;
@BeforeTest
public void setup() throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "7.0");
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
capabilities.setCapability(MobileCapabilityType.APPIUM_VERSION, "1.11.1");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "ZX1G22GRHD");
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME,"UiAutomator2");
capabilities.setCapability(MobileCapabilityType.APPLICATION_NAME, "Absolute");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
@Test
public void loadApp() {
List<MobileElement> elements = (List<MobileElement>)
driver.findElementByClassName("android.widget.EditText");
for (MobileElement element : elements) {
System.out.println(element.toJson());
}
}
}
What does Either JSONWP or W3C capabilities should be provided
mean?
@Dave Thomas, hi.
Considering official spec says that
I think You should dig into capabilities set-up.
Let me share piece of code that might be helpful for You:
Please also see this article to understand the difference between web and mobile test automation drivers and corresponding capabilities.
And also, providing the whole listing of Appium Desired Capabilities
Hope this helps for You, Regards, Eugene
Replace ApplicationName> Absolute to either App or (appPackage and appActivity)