I just spended some hours to write very first test with appium, webdriverio by reading this guide,
and found that this guide is for webdriverio v4. 馃槩
Please update guide using webdriverio v5.
In webdriverio v5,
npm install webdriverio
const opts = {
port: 4723,
desiredCapabilities: {
platformName: "Android",
platformVersion: "8.0",
deviceName: "Android Emulator",
app: "/path/to/the/downloaded/ApiDemos.apk",
automationName: "UiAutomator2"
}
};
const client = wdio.remote(opts);
node test.js
result:
2018-12-28T01:56:19.188Z DEBUG wdio-config: wdio-sync not found, running tests asynchronous
node_modules/webdriverio/src/utils.js:199
(typeof caps['appium-version'] !== 'undefined') ||
^
TypeError: Cannot read property 'appium-version' of undefined
at mobileDetector (/Users/dali/project/mathpedia-prototype/reactAim/node_modules/webdriverio/src/utils.js:199:21)
at Object.remote (/Users/dali/project/mathpedia-prototype/reactAim/node_modules/webdriverio/src/index.js:35:29)
at Object.<anonymous> (/Users/dali/project/mathpedia-prototype/reactAim/test/e2e/login.test.js:15:21)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
This is updated now. Thanks for jumping on this @saikrishna321 and thanks @iwonrimath for bringing this to our attention.
This guide is still out of date. There's an await in the sample code that is not within an async function. The guide should not present this sample code and simply say "You can try and run this test on your own. "Simply save it and execute it using node" because obviously it won't run. I'd say it is quite confusing for a complete n00b.
This has been updated on Github (https://github.com/appium/appium/blob/master/docs/en/about-appium/getting-started.md) but needs to be synced to appium.io
Most helpful comment
This is updated now. Thanks for jumping on this @saikrishna321 and thanks @iwonrimath for bringing this to our attention.